Cleanup some enums to consts

This commit is contained in:
the-djmaze 2023-04-03 10:29:26 +02:00
parent 91e60c1007
commit da2ab68fcc
13 changed files with 103 additions and 126 deletions

View file

@ -7,7 +7,6 @@ import {
import {
ComposeType,
EditorDefaultType,
FolderType
} from 'Common/EnumsUser';
@ -100,7 +99,7 @@ const
}
},
isPlainEditor = () => EditorDefaultType.Plain === SettingsUserStore.editorDefaultType(),
isPlainEditor = () => 'Plain' === SettingsUserStore.editorDefaultType(),
/**
* @param {string} prefix

View file

@ -1,6 +1,6 @@
import ko from 'ko';
import { Scope } from 'Common/Enums';
import { ScopeFolderList, ScopeMessageList } from 'Common/Enums';
import { addShortcut, stopEvent } from 'Common/Globals';
import { mailBox, settings } from 'Common/Links';
//import { setFolderETag } from 'Common/Cache';
@ -116,12 +116,12 @@ export class MailFolderList extends AbstractViewLeft {
hasher.setHash(mailBox(folder.fullNameHash, 1, search));
}
AppUserStore.focusedState(Scope.MessageList);
AppUserStore.focusedState(ScopeMessageList);
}
}
});
addShortcut('arrowup,arrowdown', '', Scope.FolderList, event => {
addShortcut('arrowup,arrowdown', '', ScopeFolderList, event => {
let items = [], index = 0;
dom.querySelectorAll('li a').forEach(node => {
if (node.offsetHeight || node.getClientRects().length) {
@ -145,17 +145,17 @@ export class MailFolderList extends AbstractViewLeft {
return false;
});
addShortcut('enter,open', '', Scope.FolderList, () => {
addShortcut('enter,open', '', ScopeFolderList, () => {
const item = qs('li a.focused');
if (item) {
AppUserStore.focusedState(Scope.MessageList);
AppUserStore.focusedState(ScopeMessageList);
item.click();
}
return false;
});
addShortcut('space', '', Scope.FolderList, () => {
addShortcut('space', '', ScopeFolderList, () => {
const item = qs('li a.focused'),
folder = item && ko.dataFor(item);
if (folder) {
@ -167,9 +167,9 @@ export class MailFolderList extends AbstractViewLeft {
return false;
});
// addShortcut('tab', 'shift', Scope.FolderList, () => {
addShortcut('escape,tab,arrowright', '', Scope.FolderList, () => {
AppUserStore.focusedState(Scope.MessageList);
// addShortcut('tab', 'shift', ScopeFolderList, () => {
addShortcut('escape,tab,arrowright', '', ScopeFolderList, () => {
AppUserStore.focusedState(ScopeMessageList);
moveAction(false);
return false;
});

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { addObservablesTo, addComputablesTo } from 'External/ko';
import { Scope } from 'Common/Enums';
import { ScopeFolderList, ScopeMessageList, ScopeMessageView } from 'Common/Enums';
import { ComposeType, FolderType, MessageSetAction } from 'Common/EnumsUser';
@ -45,7 +45,7 @@ import { ComposePopupView } from 'View/Popup/Compose';
import { MessageModel } from 'Model/Message';
import { Layout, ClientSideKeyNameMessageListSize } from 'Common/EnumsUser';
import { LayoutSideView, ClientSideKeyNameMessageListSize } from 'Common/EnumsUser';
import { setLayoutResizer } from 'Common/UtilsUser';
const
@ -426,7 +426,7 @@ export class MailMessageList extends AbstractViewRight {
}
let b = moveAction();
AppUserStore.focusedState(b ? Scope.MessageList : Scope.FolderList);
AppUserStore.focusedState(b ? ScopeMessageList : ScopeFolderList);
moveAction(!b);
}
}
@ -569,7 +569,7 @@ export class MailMessageList extends AbstractViewRight {
fToggle = () => {
let layout = SettingsUserStore.usePreviewPane();
setLayoutResizer(top, ClientSideKeyNameMessageListSize,
layout ? (Layout.SidePreview === layout ? 'Width' : 'Height') : 0
layout ? (LayoutSideView === layout ? 'Width' : 'Height') : 0
);
};
if (top) {
@ -578,14 +578,14 @@ export class MailMessageList extends AbstractViewRight {
}
}, 1);
this.selector.init(b_content, Scope.MessageList);
this.selector.init(b_content, ScopeMessageList);
addEventsListeners(dom, {
click: event => {
ThemeStore.isMobile() && !eqs(event, '.toggleLeft') && leftPanelDisabled(true);
if (eqs(event, '.messageList') && Scope.MessageView === AppUserStore.focusedState()) {
AppUserStore.focusedState(Scope.MessageList);
if (eqs(event, '.messageList') && ScopeMessageView === AppUserStore.focusedState()) {
AppUserStore.focusedState(ScopeMessageList);
}
let el = eqs(event, '.e-paginator a');
@ -667,7 +667,7 @@ export class MailMessageList extends AbstractViewRight {
// initShortcuts
addShortcut('enter,open', '', Scope.MessageList, () => {
addShortcut('enter,open', '', ScopeMessageList, () => {
if (formFieldFocused()) {
MessagelistUserStore.mainSearch(sLastSearchValue);
return false;
@ -679,42 +679,42 @@ export class MailMessageList extends AbstractViewRight {
});
// archive (zip)
registerShortcut('z', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('z', '', [ScopeMessageList, ScopeMessageView], () => {
this.archiveCommand();
return false;
});
// delete
registerShortcut('delete', 'shift', Scope.MessageList, () => {
registerShortcut('delete', 'shift', ScopeMessageList, () => {
MessagelistUserStore.listCheckedOrSelected().length && this.deleteWithoutMoveCommand();
return false;
});
// registerShortcut('3', 'shift', Scope.MessageList, () => {
registerShortcut('delete', '', Scope.MessageList, () => {
// registerShortcut('3', 'shift', ScopeMessageList, () => {
registerShortcut('delete', '', ScopeMessageList, () => {
MessagelistUserStore.listCheckedOrSelected().length && this.deleteCommand();
return false;
});
// check mail
addShortcut('r', 'meta', [Scope.FolderList, Scope.MessageList, Scope.MessageView], () => {
addShortcut('r', 'meta', [ScopeFolderList, ScopeMessageList, ScopeMessageView], () => {
this.reload();
return false;
});
// check all
registerShortcut('a', 'meta', Scope.MessageList, () => {
registerShortcut('a', 'meta', ScopeMessageList, () => {
this.checkAll(!(this.checkAll() && !this.isIncompleteChecked()));
return false;
});
// write/compose (open compose popup)
registerShortcut('w,c,new', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('w,c,new', '', [ScopeMessageList, ScopeMessageView], () => {
showMessageComposer();
return false;
});
// important - star/flag messages
registerShortcut('i', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('i', '', [ScopeMessageList, ScopeMessageView], () => {
const checked = MessagelistUserStore.listCheckedOrSelected();
if (checked.length) {
listAction(
@ -726,7 +726,7 @@ export class MailMessageList extends AbstractViewRight {
return false;
});
registerShortcut('t', '', [Scope.MessageList], () => {
registerShortcut('t', '', [ScopeMessageList], () => {
let message = MessagelistUserStore.selectedMessage() || MessagelistUserStore.focusedMessage();
if (0 < message?.threadsLen()) {
this.gotoThread(message);
@ -735,38 +735,38 @@ export class MailMessageList extends AbstractViewRight {
});
// move
registerShortcut('insert', '', Scope.MessageList, () => {
registerShortcut('insert', '', ScopeMessageList, () => {
this.moveCommand();
return false;
});
// read
registerShortcut('q', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('q', '', [ScopeMessageList, ScopeMessageView], () => {
this.seenMessagesFast(true);
return false;
});
// unread
registerShortcut('u', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('u', '', [ScopeMessageList, ScopeMessageView], () => {
this.seenMessagesFast(false);
return false;
});
registerShortcut('f,mailforward', 'shift', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('f,mailforward', 'shift', [ScopeMessageList, ScopeMessageView], () => {
this.forwardCommand();
return false;
});
if (SettingsCapa('Search')) {
// search input focus
addShortcut('/', '', [Scope.MessageList, Scope.MessageView], () => {
addShortcut('/', '', [ScopeMessageList, ScopeMessageView], () => {
this.focusSearch(true);
return false;
});
}
// cancel search
addShortcut('escape', '', Scope.MessageList, () => {
addShortcut('escape', '', ScopeMessageList, () => {
if (this.messageListSearchDesc()) {
this.cancelSearch();
return false;
@ -777,25 +777,25 @@ export class MailMessageList extends AbstractViewRight {
});
// change focused state
addShortcut('tab', 'shift', Scope.MessageList, () => {
AppUserStore.focusedState(Scope.FolderList);
addShortcut('tab', 'shift', ScopeMessageList, () => {
AppUserStore.focusedState(ScopeFolderList);
return false;
});
addShortcut('arrowleft', '', Scope.MessageList, () => {
AppUserStore.focusedState(Scope.FolderList);
addShortcut('arrowleft', '', ScopeMessageList, () => {
AppUserStore.focusedState(ScopeFolderList);
return false;
});
addShortcut('tab,arrowright', '', Scope.MessageList, () => {
addShortcut('tab,arrowright', '', ScopeMessageList, () => {
if (MessageUserStore.message()) {
AppUserStore.focusedState(Scope.MessageView);
AppUserStore.focusedState(ScopeMessageView);
return false;
}
});
addShortcut('arrowleft', 'meta', Scope.MessageView, ()=>false);
addShortcut('arrowright', 'meta', Scope.MessageView, ()=>false);
addShortcut('arrowleft', 'meta', ScopeMessageView, ()=>false);
addShortcut('arrowright', 'meta', ScopeMessageView, ()=>false);
addShortcut('f', 'meta', Scope.MessageList, this.advancedSearchClick);
addShortcut('f', 'meta', ScopeMessageList, this.advancedSearchClick);
}
advancedSearchClick() {

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
import { Scope } from 'Common/Enums';
import { ScopeMessageList, ScopeMessageView } from 'Common/Enums';
import {
ComposeType,
@ -335,23 +335,23 @@ export class MailMessageView extends AbstractViewRight {
}
});
keyScopeReal.subscribe(value => this.messageDomFocused(Scope.MessageView === value));
keyScopeReal.subscribe(value => this.messageDomFocused(ScopeMessageView === value));
// initShortcuts
// exit fullscreen, back
addShortcut('escape', '', Scope.MessageView, () => {
addShortcut('escape', '', ScopeMessageView, () => {
if (!this.viewModelDom.hidden && currentMessage()) {
const preview = SettingsUserStore.usePreviewPane();
if (isFullscreen()) {
exitFullscreen();
if (preview) {
AppUserStore.focusedState(Scope.MessageList);
AppUserStore.focusedState(ScopeMessageList);
}
} else if (!preview) {
currentMessage(null);
} else {
AppUserStore.focusedState(Scope.MessageList);
AppUserStore.focusedState(ScopeMessageList);
}
return false;
@ -359,13 +359,13 @@ export class MailMessageView extends AbstractViewRight {
});
// fullscreen
addShortcut('enter,open', '', Scope.MessageView, () => {
addShortcut('enter,open', '', ScopeMessageView, () => {
isFullscreen() || toggleFullscreen();
return false;
});
// reply
registerShortcut('r,mailreply', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('r,mailreply', '', [ScopeMessageList, ScopeMessageView], () => {
if (currentMessage()) {
this.replyCommand();
return false;
@ -374,13 +374,13 @@ export class MailMessageView extends AbstractViewRight {
});
// replyAll
registerShortcut('a', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('a', '', [ScopeMessageList, ScopeMessageView], () => {
if (currentMessage()) {
this.replyAllCommand();
return false;
}
});
registerShortcut('mailreply', 'shift', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('mailreply', 'shift', [ScopeMessageList, ScopeMessageView], () => {
if (currentMessage()) {
this.replyAllCommand();
return false;
@ -388,7 +388,7 @@ export class MailMessageView extends AbstractViewRight {
});
// forward
registerShortcut('f,mailforward', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('f,mailforward', '', [ScopeMessageList, ScopeMessageView], () => {
if (currentMessage()) {
this.forwardCommand();
return false;
@ -396,13 +396,13 @@ export class MailMessageView extends AbstractViewRight {
});
// message information
registerShortcut('i', 'meta', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('i', 'meta', [ScopeMessageList, ScopeMessageView], () => {
currentMessage() && this.toggleFullInfo();
return false;
});
// toggle message blockquotes
registerShortcut('b', '', [Scope.MessageList, Scope.MessageView], () => {
registerShortcut('b', '', [ScopeMessageList, ScopeMessageView], () => {
const message = currentMessage();
if (message?.body) {
message.body.querySelectorAll('details').forEach(node => node.open = !node.open);
@ -410,37 +410,37 @@ export class MailMessageView extends AbstractViewRight {
}
});
addShortcut('arrowup,arrowleft', 'meta', [Scope.MessageList, Scope.MessageView], () => {
addShortcut('arrowup,arrowleft', 'meta', [ScopeMessageList, ScopeMessageView], () => {
this.goUpCommand();
return false;
});
addShortcut('arrowdown,arrowright', 'meta', [Scope.MessageList, Scope.MessageView], () => {
addShortcut('arrowdown,arrowright', 'meta', [ScopeMessageList, ScopeMessageView], () => {
this.goDownCommand();
return false;
});
// delete
addShortcut('delete', '', Scope.MessageView, () => {
addShortcut('delete', '', ScopeMessageView, () => {
this.deleteCommand();
return false;
});
addShortcut('delete', 'shift', Scope.MessageView, () => {
addShortcut('delete', 'shift', ScopeMessageView, () => {
this.deleteWithoutMoveCommand();
return false;
});
// change focused state
addShortcut('arrowleft', '', Scope.MessageView, () => {
addShortcut('arrowleft', '', ScopeMessageView, () => {
if (!isFullscreen() && currentMessage() && SettingsUserStore.usePreviewPane()
&& !oMessageScrollerDom().scrollLeft) {
AppUserStore.focusedState(Scope.MessageList);
AppUserStore.focusedState(ScopeMessageList);
return false;
}
});
addShortcut('tab', 'shift', Scope.MessageView, () => {
addShortcut('tab', 'shift', ScopeMessageView, () => {
if (!isFullscreen() && currentMessage() && SettingsUserStore.usePreviewPane()) {
AppUserStore.focusedState(Scope.MessageList);
AppUserStore.focusedState(ScopeMessageList);
}
return false;
});

View file

@ -2,7 +2,7 @@ import { AppUserStore } from 'Stores/User/App';
import { AccountUserStore } from 'Stores/User/Account';
//import { FolderUserStore } from 'Stores/User/Folder';
import { Scope } from 'Common/Enums';
import { ScopeMessageList, ScopeMessageView, ScopeSettings } from 'Common/Enums';
import { settings } from 'Common/Links';
import { showScreenPopup } from 'Knoin/Knoin';
@ -112,7 +112,7 @@ export class SystemDropDownUserView extends AbstractViewRight {
}
onBuild() {
registerShortcut('m', '', [Scope.MessageList, Scope.MessageView, Scope.Settings], () => {
registerShortcut('m', '', [ScopeMessageList, ScopeMessageView, ScopeSettings], () => {
if (!this.viewModelDom.hidden) {
// exitFullscreen();
this.accountMenuDropdownTrigger(true);
@ -121,7 +121,7 @@ export class SystemDropDownUserView extends AbstractViewRight {
});
// shortcuts help
registerShortcut('?,f1,help', '', [Scope.MessageList, Scope.MessageView, Scope.Settings], () => {
registerShortcut('?,f1,help', '', [ScopeMessageList, ScopeMessageView, ScopeSettings], () => {
if (!this.viewModelDom.hidden) {
showScreenPopup(KeyboardShortcutsHelpPopupView);
return false;