From e6145249fa34fec88ed491c24391ee58b31765e9 Mon Sep 17 00:00:00 2001 From: djmaze Date: Fri, 19 Nov 2021 12:44:53 +0100 Subject: [PATCH] Bugfix: on login loading the user settings failed --- dev/App/User.js | 2 + dev/Stores/User/Settings.js | 63 +++++++++++++------ dev/Styles/User/Contacts.less | 14 +++-- dev/Styles/User/MessageList.less | 16 +++-- .../0.0.0/app/libraries/RainLoop/Actions.php | 4 +- .../app/libraries/RainLoop/Actions/User.php | 15 ++--- 6 files changed, 73 insertions(+), 41 deletions(-) diff --git a/dev/App/User.js b/dev/App/User.js index 44ec5a254..fc02d013b 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -719,6 +719,8 @@ class AppUser extends AbstractApp { AccountUserStore.email(SettingsGet('Email')); + SettingsUserStore.init(); + this.foldersReload(value => { try { if (value) { diff --git a/dev/Stores/User/Settings.js b/dev/Stores/User/Settings.js index 0783b6825..41ee906fa 100644 --- a/dev/Stores/User/Settings.js +++ b/dev/Stores/User/Settings.js @@ -7,11 +7,13 @@ import { ThemeStore } from 'Stores/Theme'; export const SettingsUserStore = new class { constructor() { - this.layout = ko - .observable(pInt(SettingsGet('Layout'))) + const self = this; + + self.layout = ko + .observable(1) .extend({ limitedList: Object.values(Layout) }); - this.editorDefaultType = ko.observable(SettingsGet('EditorDefaultType')).extend({ + self.editorDefaultType = ko.observable('Html').extend({ limitedList: [ EditorDefaultType.Html, EditorDefaultType.Plain, @@ -20,43 +22,64 @@ export const SettingsUserStore = new class { ] }); - this.messagesPerPage = ko.observable(pInt(SettingsGet('MPP'))).extend({ debounce: 999 }); + self.messagesPerPage = ko.observable(25).extend({ debounce: 999 }); - this.messageReadDelay = ko.observable(pInt(SettingsGet('MessageReadDelay'))).extend({ debounce: 999 }); + self.messageReadDelay = ko.observable(5).extend({ debounce: 999 }); - addObservablesTo(this, { - showImages: !!SettingsGet('ShowImages'), - removeColors: !!SettingsGet('RemoveColors'), - useCheckboxesInList: !!(ThemeStore.isMobile() || SettingsGet('UseCheckboxesInList')), - allowDraftAutosave: !!SettingsGet('AllowDraftAutosave'), - useThreads: !!SettingsGet('UseThreads'), - replySameFolder: !!SettingsGet('ReplySameFolder'), - hideUnsubscribed: Settings.app('useImapSubscribe') && SettingsGet('HideUnsubscribed'), - autoLogout: pInt(SettingsGet('AutoLogout')) + addObservablesTo(self, { + showImages: 0, + removeColors: 0, + useCheckboxesInList: 1, + allowDraftAutosave: 1, + useThreads: 0, + replySameFolder: 0, + hideUnsubscribed: 1, + autoLogout: 0 }); - this.usePreviewPane = ko.computed(() => Layout.NoPreview !== this.layout() && !ThemeStore.isMobile()); + self.init(); + + self.usePreviewPane = ko.computed(() => Layout.NoPreview !== self.layout() && !ThemeStore.isMobile()); const toggleLayout = () => { - const value = ThemeStore.isMobile() ? Layout.NoPreview : this.layout(); + const value = ThemeStore.isMobile() ? Layout.NoPreview : self.layout(); $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})); }; - this.layout.subscribe(toggleLayout); + self.layout.subscribe(toggleLayout); ThemeStore.isMobile.subscribe(toggleLayout); toggleLayout(); let iAutoLogoutTimer; - this.delayLogout = (() => { + self.delayLogout = (() => { clearTimeout(iAutoLogoutTimer); - if (0 < this.autoLogout() && !SettingsGet('AccountSignMe')) { + if (0 < self.autoLogout() && !SettingsGet('AccountSignMe')) { iAutoLogoutTimer = setTimeout( rl.app.logout, - this.autoLogout() * 60000 + self.autoLogout() * 60000 ); } }).throttle(5000); } + + init() { + const self = this; + self.editorDefaultType(SettingsGet('EditorDefaultType')); + + self.layout(pInt(SettingsGet('Layout'))); + self.messagesPerPage(pInt(SettingsGet('MessagesPerPage'))); + self.messageReadDelay(pInt(SettingsGet('MessageReadDelay'))); + self.autoLogout(pInt(SettingsGet('AutoLogout'))); + + self.showImages(!!SettingsGet('ShowImages')); + self.removeColors(!!SettingsGet('RemoveColors')); + self.useCheckboxesInList(!!SettingsGet('UseCheckboxesInList')); + self.allowDraftAutosave(!!SettingsGet('AllowDraftAutosave')); + self.useThreads(!!SettingsGet('UseThreads')); + self.replySameFolder(!!SettingsGet('ReplySameFolder')); + + self.hideUnsubscribed(Settings.app('useImapSubscribe') && SettingsGet('HideUnsubscribed')); + } }; diff --git a/dev/Styles/User/Contacts.less b/dev/Styles/User/Contacts.less index 936fa56e5..a14f54deb 100644 --- a/dev/Styles/User/Contacts.less +++ b/dev/Styles/User/Contacts.less @@ -76,12 +76,6 @@ font-size: 24px; line-height: 30px; } - - &.hideContactListCheckbox { - .checkboxItem { - visibility: hidden; - } - } } .e-contact-item { @@ -263,3 +257,11 @@ } } } + +html:not(rl-mobile) { + .hideContactListCheckbox { + .checkboxItem { + visibility: hidden; + } + } +} diff --git a/dev/Styles/User/MessageList.less b/dev/Styles/User/MessageList.less index e9d9f20a0..b76ce0454 100644 --- a/dev/Styles/User/MessageList.less +++ b/dev/Styles/User/MessageList.less @@ -172,13 +172,15 @@ html.rl-no-preview-pane { } } -.hideMessageListCheckbox { - .checkboxCheckAll { - visibility: hidden; - } +html:not(rl-mobile) { + .hideMessageListCheckbox { + .checkboxCheckAll { + visibility: hidden; + } - .checkboxMessage { - display: none; + .checkboxMessage { + display: none; + } } } @@ -416,7 +418,9 @@ html.rl-ctrl-key-pressed .messageListItem { order: 3; } } +} +.rl-side-preview-pane { .messageList:not(.hideMessageListCheckbox) .subjectParent { margin-left: 30px; } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index d0eca070e..1c65ae1fa 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -838,7 +838,7 @@ class Actions // user 'ShowImages' => (bool) $oConfig->Get('defaults', 'show_images', false), 'RemoveColors' => (bool) $oConfig->Get('defaults', 'remove_colors', false), - 'MPP' => (int) $oConfig->Get('webmail', 'messages_per_page', 25), + 'MessagesPerPage' => (int) $oConfig->Get('webmail', 'messages_per_page', 25), 'MessageReadDelay' => (int) $oConfig->Get('webmail', 'message_read_delay', 5), 'SoundNotification' => true, 'NotificationSound' => 'new-mail', @@ -975,7 +975,7 @@ class Actions $aResult['ShowImages'] = (bool)$oSettings->GetConf('ShowImages', $aResult['ShowImages']); $aResult['RemoveColors'] = (bool)$oSettings->GetConf('RemoveColors', $aResult['RemoveColors']); $aResult['ContactsAutosave'] = (bool)$oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']); - $aResult['MPP'] = (int)$oSettings->GetConf('MPP', $aResult['MPP']); + $aResult['MessagesPerPage'] = (int)$oSettings->GetConf('MPP', $aResult['MessagesPerPage']); $aResult['MessageReadDelay'] = (int)$oSettings->GetConf('MessageReadDelay', $aResult['MessageReadDelay']); $aResult['SoundNotification'] = (bool)$oSettings->GetConf('SoundNotification', $aResult['SoundNotification']); $aResult['NotificationSound'] = (string)$oSettings->GetConf('NotificationSound', $aResult['NotificationSound']); diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php index 2a2241642..4dd2dbfd8 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/User.php @@ -313,7 +313,7 @@ trait User } $this->setSettingsFromParams($oSettings, 'MPP', 'int', function ($iValue) { - return (int) (\in_array($iValue, array(10, 20, 30, 50, 100, 150, 200, 300)) ? $iValue : 20); + return \min(50, \max(10, $iValue)); }); $this->setSettingsFromParams($oSettings, 'Layout', 'int', function ($iValue) { @@ -548,7 +548,7 @@ trait User return $aValues; } - private function setSettingsFromParams(\RainLoop\Settings $oSettings, string $sConfigName, string $sType = 'string', ?callable $mStringCallback = null) : void + private function setSettingsFromParams(\RainLoop\Settings $oSettings, string $sConfigName, string $sType = 'string', ?callable $cCallback = null) : void { if ($this->HasActionParam($sConfigName)) { @@ -558,21 +558,22 @@ trait User default: case 'string': $sValue = (string) $sValue; - if ($mStringCallback && is_callable($mStringCallback)) - { - $sValue = $mStringCallback($sValue); + if ($cCallback) { + $sValue = $cCallback($sValue); } - $oSettings->SetConf($sConfigName, (string) $sValue); break; case 'int': $iValue = (int) $sValue; + if ($cCallback) { + $sValue = $cCallback($iValue); + } $oSettings->SetConf($sConfigName, $iValue); break; case 'bool': - $oSettings->SetConf($sConfigName, '1' === (string) $sValue); + $oSettings->SetConf($sConfigName, !empty($sValue)); break; } }