mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Cleanup shortcuts scope handling
This commit is contained in:
parent
874f2592ca
commit
60987f4623
5 changed files with 16 additions and 22 deletions
|
|
@ -6,8 +6,6 @@ export const
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
Scope = {
|
Scope = {
|
||||||
All: 'all',
|
|
||||||
None: 'none',
|
|
||||||
MessageList: 'MessageList',
|
MessageList: 'MessageList',
|
||||||
FolderList: 'FolderList',
|
FolderList: 'FolderList',
|
||||||
MessageView: 'MessageView',
|
MessageView: 'MessageView',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import { Scope } from 'Common/Enums';
|
|
||||||
|
|
||||||
let keyScopeFake = Scope.All;
|
let keyScopeFake = 'all';
|
||||||
|
|
||||||
export const
|
export const
|
||||||
ScopeMenu = 'Menu',
|
ScopeMenu = 'Menu',
|
||||||
|
|
@ -43,21 +42,20 @@ export const
|
||||||
addEventsListeners = (element, events) =>
|
addEventsListeners = (element, events) =>
|
||||||
Object.entries(events).forEach(([event, fn]) => element.addEventListener(event, fn)),
|
Object.entries(events).forEach(([event, fn]) => element.addEventListener(event, fn)),
|
||||||
|
|
||||||
// keys
|
// keys / shortcuts
|
||||||
keyScopeReal = ko.observable(Scope.All),
|
keyScopeReal = ko.observable('all'),
|
||||||
keyScope = value => {
|
keyScope = value => {
|
||||||
if (value) {
|
if (!value) {
|
||||||
if (ScopeMenu !== value) {
|
|
||||||
keyScopeFake = value;
|
|
||||||
if (dropdownVisibility()) {
|
|
||||||
value = ScopeMenu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
keyScopeReal(value);
|
|
||||||
shortcuts.setScope(value);
|
|
||||||
} else {
|
|
||||||
return keyScopeFake;
|
return keyScopeFake;
|
||||||
}
|
}
|
||||||
|
if (ScopeMenu !== value) {
|
||||||
|
keyScopeFake = value;
|
||||||
|
if (dropdownVisibility()) {
|
||||||
|
value = ScopeMenu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
keyScopeReal(value);
|
||||||
|
shortcuts.setScope(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
dropdownVisibility.subscribe(value => {
|
dropdownVisibility.subscribe(value => {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
|
import { addObservablesTo, addComputablesTo, addSubscribablesTo } from 'External/ko';
|
||||||
import { Scope } from 'Common/Enums';
|
|
||||||
import { keyScope, SettingsGet, leftPanelDisabled } from 'Common/Globals';
|
import { keyScope, SettingsGet, leftPanelDisabled } from 'Common/Globals';
|
||||||
import { ViewType, showScreenPopup } from 'Knoin/Knoin';
|
import { ViewType, showScreenPopup } from 'Knoin/Knoin';
|
||||||
|
|
||||||
|
|
@ -16,8 +15,8 @@ class AbstractView {
|
||||||
this.viewModelDom = null;
|
this.viewModelDom = null;
|
||||||
|
|
||||||
this.keyScope = {
|
this.keyScope = {
|
||||||
scope: Scope.None,
|
scope: 'none',
|
||||||
previous: Scope.None,
|
previous: 'none',
|
||||||
set: function() {
|
set: function() {
|
||||||
this.previous = keyScope();
|
this.previous = keyScope();
|
||||||
keyScope(this.scope);
|
keyScope(this.scope);
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export class MailBoxUserScreen extends AbstractScreen {
|
||||||
onShow() {
|
onShow() {
|
||||||
this.updateWindowTitle();
|
this.updateWindowTitle();
|
||||||
|
|
||||||
AppUserStore.focusedState(Scope.None);
|
AppUserStore.focusedState('none');
|
||||||
AppUserStore.focusedState(Scope.MessageList);
|
AppUserStore.focusedState(Scope.MessageList);
|
||||||
|
|
||||||
ThemeStore.isMobile() && leftPanelDisabled(true);
|
ThemeStore.isMobile() && leftPanelDisabled(true);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
|
|
||||||
import { Scope } from 'Common/Enums';
|
|
||||||
import { getNotification, i18n } from 'Common/Translator';
|
import { getNotification, i18n } from 'Common/Translator';
|
||||||
import { arrayLength } from 'Common/Utils';
|
import { arrayLength } from 'Common/Utils';
|
||||||
|
|
||||||
|
|
@ -28,7 +27,7 @@ export class PluginPopupView extends AbstractViewPopup {
|
||||||
hasConfiguration: () => 0 < this.config().length
|
hasConfiguration: () => 0 < this.config().length
|
||||||
});
|
});
|
||||||
|
|
||||||
this.keyScope.scope = Scope.All;
|
this.keyScope.scope = 'all';
|
||||||
|
|
||||||
decorateKoCommands(this, {
|
decorateKoCommands(this, {
|
||||||
saveCommand: self => self.hasConfiguration()
|
saveCommand: self => self.hasConfiguration()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue