diff --git a/components/app.js b/components/app.js index 34f6f11..3fd7bf4 100644 --- a/components/app.js +++ b/components/app.js @@ -12,6 +12,7 @@ import settingsViews from './settings' import Stats from './stats' import {headerTitles, menuTitles} from '../i18n/en/labels' import setupNotifications from '../lib/notifications' +import { closeDb } from '../db' // design wants everyhting lowercased, but we don't // have CSS pseudo properties @@ -55,7 +56,10 @@ export default class App extends Component { handleBackButtonPress = () => { const { currentPage, currentProps } = this.state - if (currentPage === HOME_PAGE) return false + if (currentPage === HOME_PAGE) { + closeDb() + return false + } if (this.isSymptomView()) { this.navigate( this.originForSymptomView, { date: currentProps.date } diff --git a/db/index.js b/db/index.js index 5fcbab0..b8ea002 100644 --- a/db/index.js +++ b/db/index.js @@ -55,6 +55,10 @@ export async function openDb (hash) { return true } +export function closeDb() { + db.close() +} + export function getBleedingDaysSortedByDate() { return db.objects('CycleDay').filtered('bleeding != null').sorted('date', true) }