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

View File

@ -103,6 +103,17 @@ export function migrateDictionary() {
migrated = true;
} else if (window.currentDictionary.version !== MIGRATE_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;
}
}