* MOB-1276: first pass
* Move realm clearing below other resets
Before we were seeing a crash where a user signsOut and while deleting realm still has a reference to a realm object somewhere the app crashes (something along the lines of "accessing object which has been invalidated or deleted", I think). Which meant that subsequent lines here after reaml.deleteAll were never hit. So, we got rid of realm but still had the signals that the user is logged in like jwt and mmkv stuff. This is problematic because UI and server request have different definitions of a user is logged in: 1) sensitive item named "username" exists, and 2) realm entry for current user exists.
I don't see how this change here get's rid of the actual crash, but at least we maybe have more likelihood of deleting all things we want to delete here.
According to @FLGMwt s investigations into this this closes MOB-820 https://linear.app/inaturalist/issue/MOB-820/user-account-seem-to-be-mixed-up#comment-80cd5378
* Do not clear auth cache and sensitive info on automatic login again initiation
I think we should fully rely on the login again action to refresh jwtToken, jwtGeneratedAt, and accessToken.
We don't know which one of them is corrupt at this point, and a re-login will give us correct new ones.
* Remove comments
A) I don't think it means that *for any reason* we delete the local database. Only when we had a 401 we were deleting everything.
B) is alleviated
* Quick fix idea
If we are on the login screen for the login again flow do not show a close button. This means the user has to close the app and open again. If the 401 persists the only action the user can take is to do the login again.
* Alternative fix: sign out on login again flow close
Adding back the X button to the login flow. Pressing it explains that this is a sign out action and signs the user out making sure we also clear realm during an entire sign out deletion flow.
* Remove test
* Update src/components/LoginSignUp/LoginForm.tsx
Co-authored-by: Ryan Stelly <ryan@inaturalist.org>
* Clean up previous code suggestion
* Revert "Clean up previous code suggestion"
This reverts commit 345bb31510.
* Revert "Update src/components/LoginSignUp/LoginForm.tsx"
This reverts commit 968fcd8601.
---------
Co-authored-by: sepeterson <10458078+sepeterson@users.noreply.github.com>
Co-authored-by: Ryan Stelly <ryan@inaturalist.org>
* Create new component for deferred startup tasks
* Function wrapper to defer a task with requestIdleCallback
* Split cache clearing into separate callbacks
So that we can interleave user interactions, I believe.
* We have no await anymore
Also add cancel by id to effect cleanup
* Move over getStorageMetrics
* Add optional timeout param
* Change order of tasks
* Add timeout to diagnostics
* Move findAndLogSentinelFiles over
* Move checkForPreviousCrash over
* Sorry, this does not belong to this PR
But since I am here already it is just a removal without consequences.
* Add TODO
* Do not return anything from findAndLogSentinelFiles
* Rename function
* Update react-native-fs.ts
We were treating every "app start" during testing as having had some sentinel files present from a previous session, i.e. having had an error during a previous camera usage session. Changing to not having sentinelFiles present seems a more sensible default for testing to me.
* Oh, git, why?
* Refactor component to hook
* add controls rozenite plugin
* refactor rozenite config to useRozenite hook
* add TODO comment for lifting up nav rozenite config
* move rozenite controls from devDeps to deps
* switch ff toggle to use..... a toggle : p
* remove temp code disabling logbox
Looking at the code of signOut it is clear that a deletion of realm only happens when we pass the Realm instance in as an option, otherwise it just passes over the code in this if block: 0480fc8b4a/src/components/LoginSignUp/AuthenticationService.ts (L229-L245)
So, since the call site here is clear that it wants to clearRealm inside of signOut adding the realm instance leads to actually deleting realm which is I think what was intended here.
* Replace usage of image-resizer with a simple file move
We are not actually resizing the image at this point. We are mainly using image-resizer here because we had to alter the rotation of the image at this point, before vision-camera supported orientation handling.
* Add file to return path
* Revert "Add file to return path"
This reverts commit 2991d13d99.
* Construct new path wit file protocol