HomePhabricator
Diffusion Comm ea7addf88f6f

[native] Add calling setDeviceID from js

Description

[native] Add calling setDeviceID from js

Summary:
Device id has to be set whenerver a user is logged in. It has to be removed when a user logs out/deletes accout.
With this approach a new id is generated when a new database gets created, or app launches and there is no id in the database.
This translates to these events:

  • user logs out/deletes their account
  • app starts/reloads and there is no id in the database for some reason
  • SQLite database gets cleared in response to currentUserInfo.anonymous changing to true or currentUserInfo.id changing to a different value for other reasons

So the id is always present in the database, apart from very short periods of time after database creation.

Test Plan:
Disable database encryption.
See that when app launches the id gets written to the database (using breakpoints and looking on the database). See that when user logs out/deletes their accout the id changes.
Run the app whithout these changes, add these changes to the code, reload the app and see that the id gets created even if a user has been logged in before the changes to the code (this imitates
what would happen for users updating their app versions when this code gets pushed to production).

Reviewers: marcin, tomek

Reviewed By: marcin, tomek

Subscribers: ashoat, atul, abosh

Differential Revision: https://phab.comm.dev/D5444