Prepare dictionary structure for changes (breaking changes)

This commit is contained in:
Robbie Antenesse 2019-07-05 10:28:32 -06:00 committed by Robbie Antenesse
parent 2ddd513098
commit 686a7fa542
2 changed files with 28 additions and 13 deletions

View File

@ -1,6 +1,6 @@
import { getTimestampInSeconds } from "./helpers"; import { getTimestampInSeconds } from "./helpers";
export const MIGRATE_VERSION = '2.0.0'; export const MIGRATE_VERSION = '2.0.1';
export const DEFAULT_DICTIONARY = { export const DEFAULT_DICTIONARY = {
name: 'New', name: 'New',
specification: 'Dictionary', specification: 'Dictionary',
@ -12,25 +12,29 @@ export const DEFAULT_DICTIONARY = {
consonants: [], consonants: [],
vowels: [], vowels: [],
blends: [], blends: [],
phonotactics: { },
onset: [], phonotactics: {
nucleus: [], onset: [],
coda: [], nucleus: [],
exceptions: '', coda: [],
}, notes: '',
}, },
orthography: { orthography: {
translations: [],
notes: '', notes: '',
}, },
grammar: { grammar: {
notes: '', notes: '',
}, },
// custom: [ custom: {
// // { css: '',
// // name: 'Example Tab', // tabs: [
// // content: `This is an _example_ tab to show how **tabs** work with [Markdown](${ MARKDOWN_LINK })!`, // {
// // } // name: 'Example Tab',
// ], // content: `This is an _example_ tab to show how **tabs** work with [Markdown](${ MARKDOWN_LINK })!`,
// }
// ],
},
}, },
words: [ words: [
/* { /* {

View File

@ -103,6 +103,17 @@ export function migrateDictionary() {
migrated = true; migrated = true;
} else if (window.currentDictionary.version !== MIGRATE_VERSION) { } else if (window.currentDictionary.version !== MIGRATE_VERSION) {
switch (window.currentDictionary.version) { switch (window.currentDictionary.version) {
case '2.0.1': {
window.currentDictionary.details.phonotactics = Object.assign({}, window.currentDictionary.details.phonology.phonotactics);
delete window.currentDictionary.details.phonology.phonotactics;
window.currentDictionary.details.phonotactics.notes = window.currentDictionary.details.phonotactics.exceptions;
delete window.currentDictionary.details.phonotactics.exceptions;
// Add window.currentDictionary.details.orthography.translations = [];
// Add window.currentDictionary.custom.css = '';
window.currentDictionary = Object.assign({}, DEFAULT_DICTIONARY, window.currentDictionary);
migrated = true;
break;
}
default: console.error('Unknown version'); break; default: console.error('Unknown version'); break;
} }
} }