From 8623bb5d60786894a5c17ebb62d52a244c6d8fa7 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Thu, 23 Feb 2023 15:43:32 +0100 Subject: [PATCH] Reduce use of isMobile() --- dev/App/User.js | 2 +- dev/Knoin/Knoin.js | 4 ++++ dev/Screen/User/MailBox.js | 6 +----- dev/Screen/User/Settings.js | 4 +--- dev/Styles/User/Layout.less | 2 +- dev/Styles/User/MessageList.less | 13 +++++++++++++ dev/View/User/MailBox/MessageList.js | 6 +----- dev/View/User/MailBox/MessageView.js | 2 -- .../app/templates/Views/User/MailMessageList.html | 12 ++++++------ 9 files changed, 28 insertions(+), 23 deletions(-) diff --git a/dev/App/User.js b/dev/App/User.js index 20874e4eb..f0956381f 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -183,7 +183,7 @@ export class AppUser extends AbstractApp { super.bootstart(); addEventListener('beforeunload', event => { - if (arePopupsVisible() || (ThemeStore.isMobile() && MessageUserStore.message())) { + if (arePopupsVisible() || (!SettingsUserStore.layout() && MessageUserStore.message())) { event.preventDefault(); return event.returnValue = i18n('POPUPS_ASK/EXIT_ARE_YOU_SURE'); } diff --git a/dev/Knoin/Knoin.js b/dev/Knoin/Knoin.js index d21eb3468..efeadd780 100644 --- a/dev/Knoin/Knoin.js +++ b/dev/Knoin/Knoin.js @@ -4,6 +4,9 @@ import { doc, $htmlCL, elementById, createElement, fireEvent } from 'Common/Glob import { forEachObjectEntry } from 'Common/Utils'; import { i18nToNodes } from 'Common/Translator'; +import { leftPanelDisabled } from 'Common/Globals'; +import { ThemeStore } from 'Stores/Theme'; + let currentScreen = null, defaultScreenName = ''; @@ -151,6 +154,7 @@ const vm.onHide?.(); destroy && vm.viewModelDom.remove(); }); + ThemeStore.isMobile() && leftPanelDisabled(true); }, /** diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js index 3ab6e80ee..867e2fc23 100644 --- a/dev/Screen/User/MailBox.js +++ b/dev/Screen/User/MailBox.js @@ -1,5 +1,5 @@ import { Scope } from 'Common/Enums'; -import { doc, createElement, leftPanelDisabled, Settings } from 'Common/Globals'; +import { doc, createElement, Settings } from 'Common/Globals'; import { pString, pInt } from 'Common/Utils'; import { moveAction } from 'Common/UtilsUser'; import { getFolderFromCacheList, getFolderFullName, getFolderInboxName } from 'Common/Cache'; @@ -9,7 +9,6 @@ import { AppUserStore } from 'Stores/User/App'; import { AccountUserStore } from 'Stores/User/Account'; import { FolderUserStore } from 'Stores/User/Folder'; import { MessagelistUserStore } from 'Stores/User/Messagelist'; -import { ThemeStore } from 'Stores/Theme'; import { SystemDropDownUserView } from 'View/User/SystemDropDown'; import { MailFolderList } from 'View/User/MailBox/FolderList'; @@ -57,11 +56,8 @@ export class MailBoxUserScreen extends AbstractScreen { */ onShow() { this.updateWindowTitle(); - AppUserStore.focusedState('none'); AppUserStore.focusedState(Scope.MessageList); - - ThemeStore.isMobile() && leftPanelDisabled(true); } /** diff --git a/dev/Screen/User/Settings.js b/dev/Screen/User/Settings.js index 69fcafe1b..11a87eca6 100644 --- a/dev/Screen/User/Settings.js +++ b/dev/Screen/User/Settings.js @@ -1,11 +1,10 @@ import { Scope } from 'Common/Enums'; -import { keyScope, leftPanelDisabled, SettingsCapa } from 'Common/Globals'; +import { keyScope, SettingsCapa } from 'Common/Globals'; import { runSettingsViewModelHooks } from 'Common/Plugins'; import { initOnStartOrLangChange, i18n } from 'Common/Translator'; import { AppUserStore } from 'Stores/User/App'; import { AccountUserStore } from 'Stores/User/Account'; -import { ThemeStore } from 'Stores/Theme'; import { AbstractSettingsScreen, settingsAddViewModel } from 'Screen/AbstractSettings'; @@ -67,7 +66,6 @@ export class SettingsUserScreen extends AbstractSettingsScreen { onShow() { this.setSettingsTitle(); keyScope(Scope.Settings); - ThemeStore.isMobile() && leftPanelDisabled(true); } setSettingsTitle() { diff --git a/dev/Styles/User/Layout.less b/dev/Styles/User/Layout.less index 487d1f7cd..129ac5338 100644 --- a/dev/Styles/User/Layout.less +++ b/dev/Styles/User/Layout.less @@ -170,7 +170,7 @@ html.rl-left-panel-disabled { left: 0; top: 0; bottom: 0; - width: 155px; + width: 50vw; z-index: 3; } .rl-left-panel-disabled #rl-left { diff --git a/dev/Styles/User/MessageList.less b/dev/Styles/User/MessageList.less index 31c9a9539..b8a494051 100644 --- a/dev/Styles/User/MessageList.less +++ b/dev/Styles/User/MessageList.less @@ -367,6 +367,19 @@ html:not(.rl-bottom-preview-pane):not(.rl-side-preview-pane) { } } +@media screen and (max-width: @maxMobileWidth) { + #V-MailMessageList .btn-toolbar:not(.hasChecked) .onCheckedShow { + display: none; + } + #V-MailMessageList .hasChecked { + .buttonCompose, + .onCheckedHide, + .sortFolder { + display: none; + } + } +} + @media screen and (min-width: @maxMobileWidth + 1px) { .messageList { .listDragOver { diff --git a/dev/View/User/MailBox/MessageList.js b/dev/View/User/MailBox/MessageList.js index c995284f1..bfcee8f86 100644 --- a/dev/View/User/MailBox/MessageList.js +++ b/dev/View/User/MailBox/MessageList.js @@ -146,10 +146,6 @@ export class MailMessageList extends AbstractViewRight { return c && MessagelistUserStore().length > c; }, - mobileCheckedStateShow: () => ThemeStore.isMobile() ? MessagelistUserStore.hasChecked() : 1, - - mobileCheckedStateHide: () => ThemeStore.isMobile() ? !MessagelistUserStore.hasChecked() : 1, - listGrouped: () => { let uid = MessagelistUserStore.threadUid(), sort = FolderUserStore.sortMode() || 'DATE'; @@ -410,7 +406,7 @@ export class MailMessageList extends AbstractViewRight { } moveCommand(vm, event) { - if (this.mobileCheckedStateShow()) { + if (MessagelistUserStore.hasChecked()) { if (vm && event?.preventDefault) { stopEvent(event); } diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index ca6902185..7e93e08f2 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -280,8 +280,6 @@ export class MailMessageView extends AbstractViewRight { onBuild(dom) { const eqs = (ev, s) => ev.target.closestWithin(s, dom); dom.addEventListener('click', event => { - ThemeStore.isMobile() && leftPanelDisabled(true); - let el = eqs(event, 'a'); if (el && 0 === event.button && mailToHelper(el.href)) { stopEvent(event); diff --git a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageList.html b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageList.html index 3008b35a7..f454239c2 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/MailMessageList.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/MailMessageList.html @@ -1,16 +1,16 @@ -