Bugfix: on login loading the user settings failed

This commit is contained in:
djmaze 2021-11-19 12:44:53 +01:00
parent 3895b7233c
commit e6145249fa
6 changed files with 73 additions and 41 deletions

View file

@ -719,6 +719,8 @@ class AppUser extends AbstractApp {
AccountUserStore.email(SettingsGet('Email')); AccountUserStore.email(SettingsGet('Email'));
SettingsUserStore.init();
this.foldersReload(value => { this.foldersReload(value => {
try { try {
if (value) { if (value) {

View file

@ -7,11 +7,13 @@ import { ThemeStore } from 'Stores/Theme';
export const SettingsUserStore = new class { export const SettingsUserStore = new class {
constructor() { constructor() {
this.layout = ko const self = this;
.observable(pInt(SettingsGet('Layout')))
self.layout = ko
.observable(1)
.extend({ limitedList: Object.values(Layout) }); .extend({ limitedList: Object.values(Layout) });
this.editorDefaultType = ko.observable(SettingsGet('EditorDefaultType')).extend({ self.editorDefaultType = ko.observable('Html').extend({
limitedList: [ limitedList: [
EditorDefaultType.Html, EditorDefaultType.Html,
EditorDefaultType.Plain, 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, { addObservablesTo(self, {
showImages: !!SettingsGet('ShowImages'), showImages: 0,
removeColors: !!SettingsGet('RemoveColors'), removeColors: 0,
useCheckboxesInList: !!(ThemeStore.isMobile() || SettingsGet('UseCheckboxesInList')), useCheckboxesInList: 1,
allowDraftAutosave: !!SettingsGet('AllowDraftAutosave'), allowDraftAutosave: 1,
useThreads: !!SettingsGet('UseThreads'), useThreads: 0,
replySameFolder: !!SettingsGet('ReplySameFolder'), replySameFolder: 0,
hideUnsubscribed: Settings.app('useImapSubscribe') && SettingsGet('HideUnsubscribed'), hideUnsubscribed: 1,
autoLogout: pInt(SettingsGet('AutoLogout')) 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 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-no-preview-pane', Layout.NoPreview === value);
$htmlCL.toggle('rl-side-preview-pane', Layout.SidePreview === value); $htmlCL.toggle('rl-side-preview-pane', Layout.SidePreview === value);
$htmlCL.toggle('rl-bottom-preview-pane', Layout.BottomPreview === value); $htmlCL.toggle('rl-bottom-preview-pane', Layout.BottomPreview === value);
dispatchEvent(new CustomEvent('rl-layout', {detail:value})); dispatchEvent(new CustomEvent('rl-layout', {detail:value}));
}; };
this.layout.subscribe(toggleLayout); self.layout.subscribe(toggleLayout);
ThemeStore.isMobile.subscribe(toggleLayout); ThemeStore.isMobile.subscribe(toggleLayout);
toggleLayout(); toggleLayout();
let iAutoLogoutTimer; let iAutoLogoutTimer;
this.delayLogout = (() => { self.delayLogout = (() => {
clearTimeout(iAutoLogoutTimer); clearTimeout(iAutoLogoutTimer);
if (0 < this.autoLogout() && !SettingsGet('AccountSignMe')) { if (0 < self.autoLogout() && !SettingsGet('AccountSignMe')) {
iAutoLogoutTimer = setTimeout( iAutoLogoutTimer = setTimeout(
rl.app.logout, rl.app.logout,
this.autoLogout() * 60000 self.autoLogout() * 60000
); );
} }
}).throttle(5000); }).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'));
}
}; };

View file

@ -76,12 +76,6 @@
font-size: 24px; font-size: 24px;
line-height: 30px; line-height: 30px;
} }
&.hideContactListCheckbox {
.checkboxItem {
visibility: hidden;
}
}
} }
.e-contact-item { .e-contact-item {
@ -263,3 +257,11 @@
} }
} }
} }
html:not(rl-mobile) {
.hideContactListCheckbox {
.checkboxItem {
visibility: hidden;
}
}
}

View file

@ -172,13 +172,15 @@ html.rl-no-preview-pane {
} }
} }
.hideMessageListCheckbox { html:not(rl-mobile) {
.checkboxCheckAll { .hideMessageListCheckbox {
visibility: hidden; .checkboxCheckAll {
} visibility: hidden;
}
.checkboxMessage { .checkboxMessage {
display: none; display: none;
}
} }
} }
@ -416,7 +418,9 @@ html.rl-ctrl-key-pressed .messageListItem {
order: 3; order: 3;
} }
} }
}
.rl-side-preview-pane {
.messageList:not(.hideMessageListCheckbox) .subjectParent { .messageList:not(.hideMessageListCheckbox) .subjectParent {
margin-left: 30px; margin-left: 30px;
} }

View file

@ -838,7 +838,7 @@ class Actions
// user // user
'ShowImages' => (bool) $oConfig->Get('defaults', 'show_images', false), 'ShowImages' => (bool) $oConfig->Get('defaults', 'show_images', false),
'RemoveColors' => (bool) $oConfig->Get('defaults', 'remove_colors', 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), 'MessageReadDelay' => (int) $oConfig->Get('webmail', 'message_read_delay', 5),
'SoundNotification' => true, 'SoundNotification' => true,
'NotificationSound' => 'new-mail', 'NotificationSound' => 'new-mail',
@ -975,7 +975,7 @@ class Actions
$aResult['ShowImages'] = (bool)$oSettings->GetConf('ShowImages', $aResult['ShowImages']); $aResult['ShowImages'] = (bool)$oSettings->GetConf('ShowImages', $aResult['ShowImages']);
$aResult['RemoveColors'] = (bool)$oSettings->GetConf('RemoveColors', $aResult['RemoveColors']); $aResult['RemoveColors'] = (bool)$oSettings->GetConf('RemoveColors', $aResult['RemoveColors']);
$aResult['ContactsAutosave'] = (bool)$oSettings->GetConf('ContactsAutosave', $aResult['ContactsAutosave']); $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['MessageReadDelay'] = (int)$oSettings->GetConf('MessageReadDelay', $aResult['MessageReadDelay']);
$aResult['SoundNotification'] = (bool)$oSettings->GetConf('SoundNotification', $aResult['SoundNotification']); $aResult['SoundNotification'] = (bool)$oSettings->GetConf('SoundNotification', $aResult['SoundNotification']);
$aResult['NotificationSound'] = (string)$oSettings->GetConf('NotificationSound', $aResult['NotificationSound']); $aResult['NotificationSound'] = (string)$oSettings->GetConf('NotificationSound', $aResult['NotificationSound']);

View file

@ -313,7 +313,7 @@ trait User
} }
$this->setSettingsFromParams($oSettings, 'MPP', 'int', function ($iValue) { $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) { $this->setSettingsFromParams($oSettings, 'Layout', 'int', function ($iValue) {
@ -548,7 +548,7 @@ trait User
return $aValues; 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)) if ($this->HasActionParam($sConfigName))
{ {
@ -558,21 +558,22 @@ trait User
default: default:
case 'string': case 'string':
$sValue = (string) $sValue; $sValue = (string) $sValue;
if ($mStringCallback && is_callable($mStringCallback)) if ($cCallback) {
{ $sValue = $cCallback($sValue);
$sValue = $mStringCallback($sValue);
} }
$oSettings->SetConf($sConfigName, (string) $sValue); $oSettings->SetConf($sConfigName, (string) $sValue);
break; break;
case 'int': case 'int':
$iValue = (int) $sValue; $iValue = (int) $sValue;
if ($cCallback) {
$sValue = $cCallback($iValue);
}
$oSettings->SetConf($sConfigName, $iValue); $oSettings->SetConf($sConfigName, $iValue);
break; break;
case 'bool': case 'bool':
$oSettings->SetConf($sConfigName, '1' === (string) $sValue); $oSettings->SetConf($sConfigName, !empty($sValue));
break; break;
} }
} }