Fix sign out after force quit in Android (#375)

Removes intentional Realm file deletion to avoid unintentional Realm file deletion, though the latter remains something of a mystery.

* Configure Realm with the full path to the file
* Remove all Realm.open calls in AuthenticationService in favor of passing the
  context/provider copy of realm (only one realm instance)
* Only delete the realm file on sign out if deleting realm contents fails for
  some reason
* Replaced deleteRealm with semantically more accurate clearRealm

Closes #373
This commit is contained in:
Ken-ichi
2023-01-23 18:34:58 -08:00
committed by GitHub
parent 08bcdfd589
commit 7a7e6619e7
20 changed files with 155 additions and 78 deletions

View File

@@ -1,5 +1,6 @@
import RNFS from "react-native-fs";
import {
consoleTransport,
fileAsyncTransport,
logger
} from "react-native-logs";
@@ -7,8 +8,16 @@ import {
const fileName = "inaturalist-rn-log.txt";
const logFilePath = `${RNFS.DocumentDirectoryPath}/${fileName}`;
// Configure without transport for test. If you want to write output during
// tests, use console.log
const transport = [];
if ( process?.env?.NODE_ENV !== "test" ) {
transport.push( consoleTransport );
transport.push( fileAsyncTransport );
}
const config = {
transport: fileAsyncTransport,
transport,
transportOptions: {
FS: RNFS,
fileName