From 9395d467120c3a6ef2d0b50d19a9bf46d0f7fa7d Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Sun, 18 Dec 2016 11:52:11 -0800 Subject: WIP --- ext/bg/js/database.js | 10 ++++++---- ext/bg/js/util.js | 8 ++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js index e596dbad..a2e334fc 100644 --- a/ext/bg/js/database.js +++ b/ext/bg/js/database.js @@ -238,13 +238,15 @@ class Database { const rows = []; for (const tag in tagMeta || {}) { const meta = tagMeta[tag]; - rows.push({ + const row = sanitizeTag({ name: tag, - category: meta.category || 'default', - notes: meta.notes || '', - order: meta.order || 0, + category: meta.category, + notes: meta.notes, + order: meta.order, dictionary: title }); + + rows.push(row); } return this.db.tagMeta.bulkAdd(rows); diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index f44ffbc8..a0fca270 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -103,6 +103,14 @@ function buildTag(name, meta) { tag[prop] = meta[symbol][prop]; } + return sanitizeTag(tag); +} + +function sanitizeTag(tag) { + tag.name = tag.name || 'untitled'; + tag.category = tag.category || 'default'; + tag.notes = tag.notes || ''; + tag.order = tag.order || 0; return tag; } -- cgit v1.2.3