Rename optionsUpdate event to optionsUpdated
Past tense better indicates that the options were changed, but no data is being included as part of the event. It is also more consistent with the other event names the yomichan object currently provides.
This commit is contained in:
parent
89cb98e4d1
commit
faf15c08aa
@ -88,7 +88,7 @@ class Backend {
|
|||||||
const callback = () => this.checkLastError(chrome.runtime.lastError);
|
const callback = () => this.checkLastError(chrome.runtime.lastError);
|
||||||
chrome.tabs.query({}, (tabs) => {
|
chrome.tabs.query({}, (tabs) => {
|
||||||
for (const tab of tabs) {
|
for (const tab of tabs) {
|
||||||
chrome.tabs.sendMessage(tab.id, {action: 'optionsUpdate', params: {source}}, callback);
|
chrome.tabs.sendMessage(tab.id, {action: 'optionsUpdated', params: {source}}, callback);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ async function settingsSaveOptions() {
|
|||||||
await apiOptionsSave(source);
|
await apiOptionsSave(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onOptionsUpdate({source}) {
|
async function onOptionsUpdated({source}) {
|
||||||
const thisSource = await settingsGetSource();
|
const thisSource = await settingsGetSource();
|
||||||
if (source === thisSource) { return; }
|
if (source === thisSource) { return; }
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ async function onReady() {
|
|||||||
|
|
||||||
storageInfoInitialize();
|
storageInfoInitialize();
|
||||||
|
|
||||||
yomichan.on('optionsUpdate', onOptionsUpdate);
|
yomichan.on('optionsUpdated', onOptionsUpdated);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(() => onReady());
|
$(document).ready(() => onReady());
|
||||||
|
@ -56,7 +56,7 @@ class Frontend extends TextScanner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
yomichan.on('orphaned', () => this.onOrphaned());
|
yomichan.on('orphaned', () => this.onOrphaned());
|
||||||
yomichan.on('optionsUpdate', () => this.updateOptions());
|
yomichan.on('optionsUpdated', () => this.updateOptions());
|
||||||
yomichan.on('zoomChanged', (e) => this.onZoomChanged(e));
|
yomichan.on('zoomChanged', (e) => this.onZoomChanged(e));
|
||||||
chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this));
|
chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this));
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ const yomichan = (() => {
|
|||||||
|
|
||||||
this._messageHandlers = new Map([
|
this._messageHandlers = new Map([
|
||||||
['getUrl', this._onMessageGetUrl.bind(this)],
|
['getUrl', this._onMessageGetUrl.bind(this)],
|
||||||
['optionsUpdate', this._onMessageOptionsUpdate.bind(this)],
|
['optionsUpdated', this._onMessageOptionsUpdated.bind(this)],
|
||||||
['zoomChanged', this._onMessageZoomChanged.bind(this)]
|
['zoomChanged', this._onMessageZoomChanged.bind(this)]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -276,8 +276,8 @@ const yomichan = (() => {
|
|||||||
return {url: window.location.href};
|
return {url: window.location.href};
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMessageOptionsUpdate({source}) {
|
_onMessageOptionsUpdated({source}) {
|
||||||
this.trigger('optionsUpdate', {source});
|
this.trigger('optionsUpdated', {source});
|
||||||
}
|
}
|
||||||
|
|
||||||
_onMessageZoomChanged({oldZoomFactor, newZoomFactor}) {
|
_onMessageZoomChanged({oldZoomFactor, newZoomFactor}) {
|
||||||
|
@ -52,7 +52,7 @@ class Display {
|
|||||||
const displayGeneratorPromise = this.displayGenerator.prepare();
|
const displayGeneratorPromise = this.displayGenerator.prepare();
|
||||||
const updateOptionsPromise = this.updateOptions(options);
|
const updateOptionsPromise = this.updateOptions(options);
|
||||||
await Promise.all([displayGeneratorPromise, updateOptionsPromise]);
|
await Promise.all([displayGeneratorPromise, updateOptionsPromise]);
|
||||||
yomichan.on('optionsUpdate', () => this.updateOptions(null));
|
yomichan.on('optionsUpdated', () => this.updateOptions(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
onError(_error) {
|
onError(_error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user