From 0232325f960b1fbe41e03f74a46fb18a7abf33f7 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 26 May 2021 20:38:15 -0400 Subject: 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 --- ext/js/data/options-util.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'ext/js/data') 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; } -- cgit v1.2.3