Only throw unexpected errors from openDb

This commit is contained in:
Julia Friesel
2018-10-30 09:14:46 +01:00
parent 7cadb01b13
commit 207b5504e7
3 changed files with 17 additions and 13 deletions
+11 -2
View File
@@ -29,16 +29,25 @@ export async function openDb ({ hash, persistConnection }) {
// open the Realm with the latest schema
realmConfig.schema = schemas[schemas.length - 1]
const connection = await Realm.open(Object.assign(
let connection
try {
connection = await Realm.open(Object.assign(
realmConfig,
schemas[schemas.length - 1]
))
} catch(err) {
if (!err.toString().includes('decrypt')) throw err
return false
}
if (persistConnection) db = connection
if (persistConnection) {
db = connection
const cycle = cycleModule()
isMensesStart = cycle.isMensesStart
getMensesDaysRightAfter = cycle.getMensesDaysRightAfter
}
return true
}
export function getBleedingDaysSortedByDate() {
return db.objects('CycleDay').filtered('bleeding != null').sorted('date', true)