dispatchEvent(new CustomEvent(...)) to fireEvent(...)

This commit is contained in:
the-djmaze 2022-02-11 12:21:16 +01:00
parent 2d46eaa783
commit 44ee236709
9 changed files with 25 additions and 21 deletions

View file

@ -1,5 +1,5 @@
import * as Links from 'Common/Links';
import { doc, SettingsGet } from 'Common/Globals';
import { doc, SettingsGet, fireEvent } from 'Common/Globals';
let notificator = null,
player = null,
@ -12,7 +12,7 @@ let notificator = null,
player.src = url;
player.play();
name = name.trim();
dispatchEvent(new CustomEvent('audio.start', {detail:name.replace(/\.([a-z0-9]{3})$/, '') || 'audio'}));
fireEvent('audio.start', name.replace(/\.([a-z0-9]{3})$/, '') || 'audio');
}
},
@ -89,7 +89,7 @@ export const SMAudio = new class {
pause() {
player && player.pause();
dispatchEvent(new CustomEvent('audio.stop'));
fireEvent('audio.stop');
}
playMp3(url, name) {

View file

@ -29,6 +29,8 @@ export const
return el;
},
fireEvent = (name, detail) => dispatchEvent(new CustomEvent(name, {detail:detail})),
// keys
keyScopeReal = ko.observable(Scope.All),
keyScope = value => {

View file

@ -1,6 +1,6 @@
import ko from 'ko';
import { koComputable } from 'External/ko';
import { doc, $htmlCL, elementById } from 'Common/Globals';
import { doc, $htmlCL, elementById, fireEvent } from 'Common/Globals';
import { isFunction, forEachObjectValue, forEachObjectEntry } from 'Common/Utils';
let
@ -137,7 +137,7 @@ const
vm.registerPopupKeyDown();
}
dispatchEvent(new CustomEvent('rl-view-model', {detail:vm}));
fireEvent('rl-view-model', vm);
} else {
console.log('Cannot find view model position: ' + position);
}

View file

@ -4,7 +4,7 @@ import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { isArray, getKeyByValue, forEachObjectEntry, b64EncodeJSONSafe } from 'Common/Utils';
import { ClientSideKeyName, FolderType, FolderMetadataKeys } from 'Common/EnumsUser';
import { getFolderFromCacheList, setFolder, setFolderInboxName, setFolderHash } from 'Common/Cache';
import { Settings, SettingsGet } from 'Common/Globals';
import { Settings, SettingsGet, fireEvent } from 'Common/Globals';
import * as Local from 'Storage/Client';
@ -394,7 +394,7 @@ export class FolderModel extends AbstractModel {
messageCountUnread: unread => {
if (FolderType.Inbox === folder.type()) {
dispatchEvent(new CustomEvent('mailbox.inbox-unread-count', {detail:unread}));
fireEvent('mailbox.inbox-unread-count', unread);
}
}
});

View file

@ -1,6 +1,7 @@
import { SMAudio } from 'Common/Audio';
import * as Links from 'Common/Links';
import { addObservablesTo } from 'Common/Utils';
import { fireEvent } from 'Common/Globals';
/**
* Might not work due to the new ServiceWorkerRegistration.showNotification
@ -12,7 +13,7 @@ const HTML5Notification = window.Notification,
dispatchMessage = data => {
focus();
if (data.Folder && data.Uid) {
dispatchEvent(new CustomEvent('mailbox.message.show', {detail:data}));
fireEvent('mailbox.message.show', data);
} else if (data.Url) {
rl.route.setHash(data.Url);
}

View file

@ -3,7 +3,7 @@ import { koComputable } from 'External/ko';
import { Layout, EditorDefaultType } from 'Common/EnumsUser';
import { pInt, addObservablesTo } from 'Common/Utils';
import { $htmlCL, SettingsGet } from 'Common/Globals';
import { $htmlCL, SettingsGet, fireEvent } from 'Common/Globals';
import { ThemeStore } from 'Stores/Theme';
export const SettingsUserStore = new class {
@ -48,7 +48,7 @@ export const SettingsUserStore = new class {
$htmlCL.toggle('rl-no-preview-pane', Layout.NoPreview === value);
$htmlCL.toggle('rl-side-preview-pane', Layout.SidePreview === value);
$htmlCL.toggle('rl-bottom-preview-pane', Layout.BottomPreview === value);
dispatchEvent(new CustomEvent('rl-layout', {detail:value}));
fireEvent('rl-layout', value);
};
self.layout.subscribe(toggleLayout);
ThemeStore.isMobile.subscribe(toggleLayout);

View file

@ -13,7 +13,7 @@ import {
import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { doc, leftPanelDisabled, moveAction, Settings, SettingsCapa, SettingsGet } from 'Common/Globals';
import { doc, leftPanelDisabled, moveAction, Settings, SettingsCapa, SettingsGet, fireEvent } from 'Common/Globals';
import { computedPaginatorHelper, showMessageComposer, folderListOptionsBuilder } from 'Common/UtilsUser';
import { FileInfo } from 'Common/File';
@ -683,7 +683,7 @@ export class MailMessageList extends AbstractViewRight {
shortcuts.add('enter,open', '', Scope.MessageList, () => {
if (MessageUserStore.message() && this.useAutoSelect()) {
dispatchEvent(new CustomEvent('mailbox.message-view.toggle-full-screen'));
fireEvent('mailbox.message-view.toggle-full-screen');
return false;
}
});

View file

@ -23,7 +23,8 @@ import {
Settings,
SettingsCapa,
getFullscreenElement,
exitFullscreen
exitFullscreen,
fireEvent
} from 'Common/Globals';
import { arrayLength, inFocus } from 'Common/Utils';
@ -245,15 +246,15 @@ export class MailMessageView extends AbstractViewRight {
}
goUpCommand() {
dispatchEvent(new CustomEvent('mailbox.message-list.selector.go-up',
{detail:SettingsUserStore.usePreviewPane() || !!currentMessage()} // bForceSelect
));
fireEvent('mailbox.message-list.selector.go-up',
SettingsUserStore.usePreviewPane() || !!currentMessage() // bForceSelect
);
}
goDownCommand() {
dispatchEvent(new CustomEvent('mailbox.message-list.selector.go-down',
{detail:SettingsUserStore.usePreviewPane() || !!currentMessage()} // bForceSelect
));
fireEvent('mailbox.message-list.selector.go-down',
SettingsUserStore.usePreviewPane() || !!currentMessage() // bForceSelect
);
}
toggleFullScreen() {

View file

@ -13,7 +13,7 @@ import { KeyboardShortcutsHelpPopupView } from 'View/Popup/KeyboardShortcutsHelp
import { AccountPopupView } from 'View/Popup/Account';
import { ContactsPopupView } from 'View/Popup/Contacts';
import { doc, Settings/*, SettingsGet*/, leftPanelDisabled } from 'Common/Globals';
import { doc, Settings/*, SettingsGet*/, leftPanelDisabled, fireEvent } from 'Common/Globals';
import { ThemeStore } from 'Stores/Theme';
@ -49,7 +49,7 @@ export class SystemDropDownUserView extends AbstractViewRight {
}
stopPlay() {
dispatchEvent(new CustomEvent('audio.api.stop'));
fireEvent('audio.api.stop');
}
accountClick(account, event) {