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'));
SettingsUserStore.init();
this.foldersReload(value => {
try {
if (value) {

View file

@ -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'));
}
};

View file

@ -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;
}
}
}

View file

@ -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;
}

View file

@ -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']);

View file

@ -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;
}
}