Bring back persist argument to openDb

This reverts commit fc1028dba411711c46e3976693552632af4b9dc6.
This commit is contained in:
Julia Friesel
2018-09-14 20:24:16 +02:00
parent 8e8f6fcf6c
commit 9f11170f8b
2 changed files with 7 additions and 5 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ export default class PasswordPrompt extends Component {
if (hasEncryption) {
this.setState({showPasswordPrompt: true})
} else {
await openDb()
await openDb({persistConnection: true})
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(msg.message)
await openDb({hash: msg.message, persistConnection: true })
} catch (err) {
Alert.alert(
shared.incorrectPassword,
+5 -3
View File
@@ -161,12 +161,14 @@ export function requestHash(pw) {
}))
}
export async function openDb (hash) {
export async function openDb ({ hash, persistConnection }) {
if (hash) {
realmConfig.encryptionKey = hashToInt8Array(hash)
}
db = await Realm.open(realmConfig)
const connection = await Realm.open(realmConfig)
if (persistConnection) db = connection
}
export async function changeEncryptionAndRestartApp(hash) {
@@ -195,7 +197,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()
await openDb({ persistConnection: true })
await saveEncryptionFlag(false)
}