aboutsummaryrefslogtreecommitdiff
path: root/ext/js/display/display.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-28 22:17:38 -0500
committerGitHub <noreply@github.com>2023-12-29 03:17:38 +0000
commit1e254fd1d4423b984e176547ef36a14383bbd7f5 (patch)
tree8aae2c47f80265d5f1f39c927e19455ec3986387 /ext/js/display/display.js
parenta51ae1533c54162f14785652e9128f90afb86aed (diff)
Event dispatcher refactor (#463)
* Refactor EventDispatcher template type * Update core types * Update log * Update clipboard monitor * Update application events * Update popup events * Update text scanner * Update cross frame API * Update display events * Type updates * Update display history * Update query parser * Update search persistent state controller * Update panel element * Update popup menu * Update audio system * Update hotkey handler * Update settings controller * Update audio controller * Update types * Update types * Update types * Add event handler types * Update type * Fix issues * Remove error suppression * Fix typo
Diffstat (limited to 'ext/js/display/display.js')
-rw-r--r--ext/js/display/display.js32
1 files changed, 10 insertions, 22 deletions
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index 79cf79a8..08f640d0 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -34,7 +34,7 @@ import {OptionToggleHotkeyHandler} from './option-toggle-hotkey-handler.js';
import {QueryParser} from './query-parser.js';
/**
- * @augments EventDispatcher<import('display').DisplayEventType>
+ * @augments EventDispatcher<import('display').Events>
*/
export class Display extends EventDispatcher {
/**
@@ -449,9 +449,7 @@ export class Display extends EventDispatcher {
this._updateNestedFrontend(options);
this._updateContentTextScanner(options);
- /** @type {import('display').OptionsUpdatedEvent} */
- const event = {options};
- this.trigger('optionsUpdated', event);
+ this.trigger('optionsUpdated', {options});
}
/**
@@ -716,9 +714,7 @@ export class Display extends EventDispatcher {
*/
_onMessageVisibilityChanged({value}) {
this._frameVisible = value;
- /** @type {import('display').FrameVisibilityChangeEvent} */
- const event = {value};
- this.trigger('frameVisibilityChange', event);
+ this.trigger('frameVisibilityChange', {value});
}
/** */
@@ -796,7 +792,7 @@ export class Display extends EventDispatcher {
}
/**
- * @param {import('display').QueryParserSearchedEvent} details
+ * @param {import('query-parser').EventArgument<'searched'>} details
*/
_onQueryParserSearch({type, dictionaryEntries, sentence, inputInfo: {eventType}, textSource, optionsContext, sentenceOffset}) {
const query = textSource.text();
@@ -869,7 +865,7 @@ export class Display extends EventDispatcher {
}
/**
- * @param {import('dynamic-property').ChangeEventDetails<boolean>} details
+ * @param {import('dynamic-property').EventArgument<boolean, 'change'>} details
*/
_onProgressIndicatorVisibleChanged({value}) {
if (this._progressIndicatorTimer !== null) {
@@ -1646,7 +1642,7 @@ export class Display extends EventDispatcher {
/** */
_closePopups() {
- yomitan.trigger('closePopups');
+ yomitan.triggerClosePopups();
}
/**
@@ -2011,9 +2007,7 @@ export class Display extends EventDispatcher {
/** @type {Promise<unknown>[]} */
const promises = [];
- /** @type {import('display').LogDictionaryEntryDataEvent} */
- const event = {dictionaryEntry, promises};
- this.trigger('logDictionaryEntryData', event);
+ this.trigger('logDictionaryEntryData', {dictionaryEntry, promises});
if (promises.length > 0) {
for (const result2 of await Promise.all(promises)) {
Object.assign(result, result2);
@@ -2031,9 +2025,7 @@ export class Display extends EventDispatcher {
/** */
_triggerContentUpdateStart() {
- /** @type {import('display').ContentUpdateStartEvent} */
- const event = {type: this._contentType, query: this._query};
- this.trigger('contentUpdateStart', event);
+ this.trigger('contentUpdateStart', {type: this._contentType, query: this._query});
}
/**
@@ -2042,15 +2034,11 @@ export class Display extends EventDispatcher {
* @param {number} index
*/
_triggerContentUpdateEntry(dictionaryEntry, element, index) {
- /** @type {import('display').ContentUpdateEntryEvent} */
- const event = {dictionaryEntry, element, index};
- this.trigger('contentUpdateEntry', event);
+ this.trigger('contentUpdateEntry', {dictionaryEntry, element, index});
}
/** */
_triggerContentUpdateComplete() {
- /** @type {import('display').ContentUpdateCompleteEvent} */
- const event = {type: this._contentType};
- this.trigger('contentUpdateComplete', event);
+ this.trigger('contentUpdateComplete', {type: this._contentType});
}
}