From 2587b9ae6bb9a9b5f4fc5dd17a7f043c17596a06 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 13 Nov 2016 12:49:28 -0800 Subject: [PATCH] Dictionary simplification --- ext/bg/js/database.js | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index 4c8703c3..6a171dd4 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -20,11 +20,10 @@ class Database { constructor() { this.db = null; - this.dbVer = 6; this.entities = {}; } - init() { + prepare() { if (this.db !== null) { return Promise.reject('database already initialized'); } @@ -35,41 +34,9 @@ class Database { kanji: '++, dictionary, character', entities: '++, dictionary', dictionaries: '++, title, version', - meta: 'name, value', }); - return Promise.resolve(); - } - - prepare() { - this.init(); - - return this.db.meta.get('version').then(row => { - return row ? row.value : 0; - }).catch(() => { - return 0; - }).then(version => { - if (this.dbVer === version) { - return true; - } - - const db = this.db; - this.db.close(); - this.db = null; - - return db.delete().then(() => { - this.init(); - return false; - }); - }); - } - - seal() { - if (this.db === null) { - return Promise.reject('database not initialized'); - } - - return this.db.meta.put({name: 'version', value: this.dbVer}); + return this.db.open(); } findTerm(term, dictionaries) {