[web] Initialize database at startup on safari
Summary:
Part of ENG-4844
Fixed ENG-4878
Depends on D9107
On safari we need to start database before rehydration like on other browsers. This is done by initializing the database in getDatabaseModule, so as soon as it's called somewhere we make sure the database is ready to go. This diff also merges initForDBForLoggedInUser, init, and constructor because there was some code duplication.
Test Plan:
Test in safari and in chromium:
- check if there's "Database initialization success" when logging in and when reloading when logged in
- check if clearSensitiveData is called after logging out
- check if draft are still there after reload (drafts are persisted with db operations)
- check if selected apps are still there after reload (selected apps are persisted with standard redux persist mechanism)
Reviewers: kamil, atul, inka, tomek, ashoat
Reviewed By: kamil, ashoat
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D9108