Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[web] Move getSafariEncryptionKey to initPromise
Summary: [ENG-5670](https://linear.app/comm/issue/ENG-5670) Webapp on safari didn't correctly initialize the database and so rehydration failed. Because cookies are now stored in redux it also meant that the user was logged out. The problem was that the async call to `getSafariEncryptionKey` (which only happens on safari) wasn't in `this.initPromise`. That meant we could end up in a situation where `this.status` is `INIT_IN_PROGRESS` but `initPromise` is undefined. This broke logic in `isDatabaseSupported` which assumed that these two variables would be always in sync. Test Plan: Added logs to `DatabaseModule.isDatabaseSupported` and `commReduxStorageEngine.getItem` (which tries to get data from sqlite and internally calls `isDatabaseSupported`) Without changes in this diff: - Reloaded the website - From logs in `isDatabaseSupported` we can see that - `this.status` is `INIT_IN_PROGRESS` which is correct - But `this.initPromise` in `undefined` - `isDatabaseSupported` call in `getItem` returns false and rehydration fails - User is logged out With changes: - Reloaded the website - Now `this.initPromise` contains a pending promise - `isDatabaseSupported` call in `getItem` returns true - User is remains logged in Reviewers: kamil, ashoat, tomek Reviewed By: tomek Subscribers: wyilio Differential Revision: https://phab.comm.dev/D9739
- Loading branch information