From 1c5c6a804b78c06be3c6eda1145a24e4a97e261a Mon Sep 17 00:00:00 2001 From: Julia Friesel Date: Fri, 14 Sep 2018 18:57:55 +0200 Subject: [PATCH] Remove unneeded argument to openDb --- components/password-prompt.js | 4 ++-- db/index.js | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/components/password-prompt.js b/components/password-prompt.js index 78d1b93..d86ea6e 100644 --- a/components/password-prompt.js +++ b/components/password-prompt.js @@ -18,7 +18,7 @@ export default class PasswordPrompt extends Component { if (hasEncryption) { this.setState({showPasswordPrompt: true}) } else { - await openDb({persistConnection: true}) + await openDb() this.props.showApp() } }) @@ -34,7 +34,7 @@ export default class PasswordPrompt extends Component { msg = JSON.parse(msg) if (msg.type != 'sha512') return try { - await openDb({hash: msg.message, persistConnection: true }) + await openDb(msg.message) } catch (err) { Alert.alert( shared.incorrectPassword, diff --git a/db/index.js b/db/index.js index 4173c1d..9745327 100644 --- a/db/index.js +++ b/db/index.js @@ -161,14 +161,12 @@ export function requestHash(pw) { })) } -export async function openDb ({ hash, persistConnection }) { +export async function openDb (hash) { if (hash) { realmConfig.encryptionKey = hashToInt8Array(hash) } - const connection = await Realm.open(realmConfig) - - if (persistConnection) db = connection + db = await Realm.open(realmConfig) } export async function changeEncryptionAndRestartApp(hash) { @@ -197,7 +195,7 @@ export async function changeEncryptionAndRestartApp(hash) { export async function deleteDbAndOpenNew() { const exists = await fs.exists(Realm.defaultPath) if (exists) await fs.unlink(Realm.defaultPath) - await openDb({ persistConnection: true }) + await openDb() await saveEncryptionFlag(false) }