diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-05-26 20:38:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-26 20:38:15 -0400 |
commit | 0232325f960b1fbe41e03f74a46fb18a7abf33f7 (patch) | |
tree | 4b9552f3b0db91daab394c4047add01d32e17d44 /ext/js/data/options-util.js | |
parent | 900bceda47e4c736e70a66e66cfce719b4c6d203 (diff) |
Refactor json audio source (#1711)
* Move sources to the end of audio options object
* Add custom-json audio source type
* Add support for downloading custom-json
* Remove customSourceType
Diffstat (limited to 'ext/js/data/options-util.js')
-rw-r--r-- | ext/js/data/options-util.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 740afa76..89d50903 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -817,11 +817,25 @@ class OptionsUtil { // Version 12 changes: // Changed sentenceParsing.enableTerminationCharacters to sentenceParsing.terminationCharacterMode. // Added {search-query} field marker. + // Updated audio.sources[] to change 'custom' into 'custom-json'. + // Removed audio.customSourceType. await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v12.handlebars'); for (const profile of options.profiles) { - const {sentenceParsing} = profile.options; + const {sentenceParsing, audio} = profile.options; + sentenceParsing.terminationCharacterMode = sentenceParsing.enableTerminationCharacters ? 'custom' : 'newlines'; delete sentenceParsing.enableTerminationCharacters; + + const {sources, customSourceType} = audio; + audio.sources = sources.map((type) => { + switch (type) { + case 'custom': + return (customSourceType === 'json' ? 'custom-json' : 'custom'); + default: + return type; + } + }); + delete audio.customSourceType; } return options; } |