Skip to content

Commit

Permalink
TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
toasted-nutbread committed Mar 21, 2020
1 parent 647769f commit 377b20e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ext/bg/js/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* ClipboardMonitor
* JsonSchema
* Mecab
* ObjectPropertyAccessor
* Translator
* conditionsTestValue
* dictConfigured
Expand Down Expand Up @@ -76,6 +77,7 @@ class Backend {
['optionsGet', this._onApiOptionsGet.bind(this)],
['optionsGetFull', this._onApiOptionsGetFull.bind(this)],
['optionsSet', this._onApiOptionsSet.bind(this)],
['optionsModify', this._onApiOptionsModify.bind(this)],
['optionsSave', this._onApiOptionsSave.bind(this)],
['kanjiFind', this._onApiKanjiFind.bind(this)],
['termsFind', this._onApiTermsFind.bind(this)],
Expand Down Expand Up @@ -366,6 +368,13 @@ class Backend {
await this._onApiOptionsSave({source});
}

async _onApiOptionsModify({source, modifications}) {

Check failure on line 371 in ext/bg/js/backend.js

View workflow job for this annotation

GitHub Actions / test

'source' is defined but never used. Allowed unused args must match /^_/u
for (const modification of modifications) {

Check failure on line 372 in ext/bg/js/backend.js

View workflow job for this annotation

GitHub Actions / test

'modification' is assigned a value but never used
// TODO :
}
// TODO
}

async _onApiOptionsSave({source}) {
const options = this.getFullOptions();
await optionsSave(options);
Expand Down Expand Up @@ -783,6 +792,28 @@ class Backend {

// Utilities

_modifyOptions(modification) {
switch (modification.type) {
case 'set':
{
const {optionsContext, path, value} = modification;
const pathArray = Array.isArray(path) ? path : ObjectPropertyAccessor.getPathArray(path);
const options = (
typeof optionsContext === 'object' &&
optionsContext !== null ?
this.getOptions(optionsContext) :
this.options
);

const schema = null; // TODO
const optionsProxy = JsonSchema.createProxy(options, schema);
const accessor = new ObjectPropertyAccessor(optionsProxy); // TODO : Need a setter with schema validation
accessor.setProperty(pathArray, value);
}
break;
}
}

async _getAudioUri(definition, source, details) {
let optionsContext = (typeof details === 'object' && details !== null ? details.optionsContext : null);
if (!(typeof optionsContext === 'object' && optionsContext !== null)) {
Expand Down
4 changes: 4 additions & 0 deletions ext/mixed/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function apiOptionsSet(changedOptions, optionsContext, source) {
return _apiInvoke('optionsSet', {changedOptions, optionsContext, source});
}

function apiOptionsModify(source, modifications) {
return _apiInvoke('optionsModify', {source, modifications});
}

function apiOptionsSave(source) {
return _apiInvoke('optionsSave', {source});
}
Expand Down

0 comments on commit 377b20e

Please sign in to comment.