This commit is contained in:
Alex Yatskov 2016-12-18 11:52:11 -08:00
parent e5275560ce
commit 9395d46712
2 changed files with 14 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}