Convert getDefaultOptions to a utility function (#1235)

This commit is contained in:
toasted-nutbread 2021-01-14 19:14:29 -05:00 committed by GitHub
parent c1e4741f22
commit 39741bf1d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -17,6 +17,7 @@
/* global /* global
* HtmlTemplateCollection * HtmlTemplateCollection
* OptionsUtil
* api * api
*/ */
@ -124,6 +125,13 @@ class SettingsController extends EventDispatcher {
return this._templates.instantiateFragment(name); return this._templates.instantiateFragment(name);
} }
async getDefaultOptions() {
const optionsUtil = new OptionsUtil();
await optionsUtil.prepare();
const optionsFull = optionsUtil.getDefault();
return optionsFull;
}
// Private // Private
_setProfileIndex(value) { _setProfileIndex(value) {

View File

@ -15,10 +15,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
/* global
* OptionsUtil
*/
class SentenceTerminationCharactersController { class SentenceTerminationCharactersController {
constructor(settingsController) { constructor(settingsController) {
this._settingsController = settingsController; this._settingsController = settingsController;
@ -135,18 +131,11 @@ class SentenceTerminationCharactersController {
} }
async _reset() { async _reset() {
const defaultOptions = await this._getDefaultOptions(); const defaultOptions = await this._settingsController.getDefaultOptions();
const value = defaultOptions.profiles[0].options.sentenceParsing.terminationCharacters; const value = defaultOptions.profiles[0].options.sentenceParsing.terminationCharacters;
await this._settingsController.setProfileSetting('sentenceParsing.terminationCharacters', value); await this._settingsController.setProfileSetting('sentenceParsing.terminationCharacters', value);
await this._updateOptions(); await this._updateOptions();
} }
async _getDefaultOptions() {
const optionsUtil = new OptionsUtil();
await optionsUtil.prepare();
const optionsFull = optionsUtil.getDefault();
return optionsFull;
}
} }
class SentenceTerminationCharacterEntry { class SentenceTerminationCharacterEntry {