Some account switch reload improvements

This commit is contained in:
djmaze 2021-11-12 09:36:08 +01:00
parent 9b0f9be23c
commit ce413b7b7a
7 changed files with 41 additions and 37 deletions

View file

@ -23,11 +23,9 @@ export class AbstractApp {
this.Remote = Remote; this.Remote = Remote;
} }
logoutReload(close = false) { logoutReload() {
const url = logoutLink(); const url = logoutLink();
close && window.close && window.close();
if (location.href !== url) { if (location.href !== url) {
setTimeout(() => (Settings.app('inIframe') ? parent : window).location.href = url, 100); setTimeout(() => (Settings.app('inIframe') ? parent : window).location.href = url, 100);
} else { } else {

View file

@ -708,7 +708,7 @@ class AppUser extends AbstractApp {
} }
logout() { logout() {
Remote.logout(() => rl.logoutReload(!!SettingsGet('ParentEmail'))); Remote.logout(() => rl.logoutReload());
} }
bootstart() { bootstart() {

View file

@ -162,12 +162,11 @@ const
}); });
}, },
hideScreen = (screenToHide, destroy) => { hideScreen = screenToHide => {
screenToHide.onHide && screenToHide.onHide(); screenToHide.onHide && screenToHide.onHide();
forEachViewModel(screenToHide, (vm, dom) => { forEachViewModel(screenToHide, (vm, dom) => {
dom.hidden = true; dom.hidden = true;
vm.onHide && vm.onHide(); vm.onHide && vm.onHide();
destroy && vm.viewModelDom.remove();
}); });
}, },
@ -319,7 +318,7 @@ export const
*/ */
startScreens = screensClasses => { startScreens = screensClasses => {
hasher.clear(); hasher.clear();
forEachObjectValue(SCREENS, screen => hideScreen(screen, 1)); forEachObjectValue(SCREENS, screen => hideScreen(screen));
SCREENS = {}; SCREENS = {};
currentScreen = null, currentScreen = null,
defaultScreenName = ''; defaultScreenName = '';

View file

@ -25,25 +25,6 @@ const urlSafeJSON = data => btoa(JSON.stringify(data))
.replace(/=+$/, ''); .replace(/=+$/, '');
class RemoteUserFetch extends AbstractFetchRemote { class RemoteUserFetch extends AbstractFetchRemote {
/**
* @param {?Function} fCallback
*/
folders(fCallback) {
this.defaultRequest(
fCallback,
'Folders',
{
SentFolder: SettingsGet('SentFolder'),
DraftFolder: SettingsGet('DraftFolder'),
SpamFolder: SettingsGet('SpamFolder'),
TrashFolder: SettingsGet('TrashFolder'),
ArchiveFolder: SettingsGet('ArchiveFolder')
},
null,
'',
['Folders']
);
}
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
@ -651,6 +632,9 @@ class RemoteUserFetch extends AbstractFetchRemote {
this.defaultRequest(fCallback, 'ClearUserBackground'); this.defaultRequest(fCallback, 'ClearUserBackground');
} }
/**
* @param {?Function} fCallback
*/
foldersReload(fCallback) { foldersReload(fCallback) {
this.abort('Folders') this.abort('Folders')
.postRequest('Folders', FolderUserStore.foldersLoading) .postRequest('Folders', FolderUserStore.foldersLoading)

View file

@ -18,6 +18,7 @@ import { ThemeStore } from 'Stores/Theme';
import Remote from 'Remote/User/Fetch'; import Remote from 'Remote/User/Fetch';
import { getNotification } from 'Common/Translator'; import { getNotification } from 'Common/Translator';
//import { FolderUserStore } from 'Stores/User/Folder';
export class SystemDropDownUserView extends AbstractViewRight { export class SystemDropDownUserView extends AbstractViewRight {
constructor() { constructor() {
@ -60,8 +61,15 @@ export class SystemDropDownUserView extends AbstractViewRight {
showScreenPopup(AccountPopupView, [account]); showScreenPopup(AccountPopupView, [account]);
} }
} else { } else {
// This does not work yet /*
// rl.setData(oData.Result); // This does not work yet:
FolderUserStore.folderList([]);
MessageUserStore.list([]);
Object.entries(oData.Result).forEach((key, value) => rl.settings.set(key, value));
3. reload Folders = Remote.foldersReload
4. Change to INBOX = reload MessageList
*/
// rl.route.reload();
location.reload(); location.reload();
} }
}, 'AccountSwitch', {Email:account.email} }, 'AccountSwitch', {Email:account.email}

View file

@ -876,8 +876,6 @@ class Actions
if (!$bAdmin) { if (!$bAdmin) {
$oAccount = $this->getAccountFromToken(false); $oAccount = $this->getAccountFromToken(false);
if ($oAccount) { if ($oAccount) {
$oAddressBookProvider = $this->AddressBookProvider($oAccount);
$aResult['Auth'] = true; $aResult['Auth'] = true;
$aResult['Email'] = $oAccount->Email(); $aResult['Email'] = $oAccount->Email();
$aResult['IncLogin'] = $oAccount->IncLogin(); $aResult['IncLogin'] = $oAccount->IncLogin();
@ -885,7 +883,7 @@ class Actions
$aResult['AccountHash'] = $oAccount->Hash(); $aResult['AccountHash'] = $oAccount->Hash();
// $aResult['AccountSignMe'] = $oAccount->SignMe(); // $aResult['AccountSignMe'] = $oAccount->SignMe();
$aResult['AccountSignMe'] = false; $aResult['AccountSignMe'] = false;
$aResult['ContactsIsAllowed'] = $oAddressBookProvider->IsActive(); $aResult['ContactsIsAllowed'] = $this->AddressBookProvider($oAccount)->IsActive();
$aResult['ContactsSyncIsAllowed'] = (bool)$oConfig->Get('contacts', 'allow_sync', false); $aResult['ContactsSyncIsAllowed'] = (bool)$oConfig->Get('contacts', 'allow_sync', false);
$aResult['ContactsSyncInterval'] = (int)$oConfig->Get('contacts', 'sync_interval', 20); $aResult['ContactsSyncInterval'] = (int)$oConfig->Get('contacts', 'sync_interval', 20);
@ -936,6 +934,8 @@ class Actions
$aResult['TrashFolder'] = (string)$oSettingsLocal->GetConf('TrashFolder', ''); $aResult['TrashFolder'] = (string)$oSettingsLocal->GetConf('TrashFolder', '');
$aResult['ArchiveFolder'] = (string)$oSettingsLocal->GetConf('ArchiveFolder', ''); $aResult['ArchiveFolder'] = (string)$oSettingsLocal->GetConf('ArchiveFolder', '');
$aResult['HideUnsubscribed'] = (bool)$oSettingsLocal->GetConf('HideUnsubscribed', $aResult['HideUnsubscribed']); $aResult['HideUnsubscribed'] = (bool)$oSettingsLocal->GetConf('HideUnsubscribed', $aResult['HideUnsubscribed']);
$aResult['UseThreads'] = (bool)$oSettingsLocal->GetConf('UseThreads', $aResult['UseThreads']);
$aResult['ReplySameFolder'] = (bool)$oSettingsLocal->GetConf('ReplySameFolder', $aResult['ReplySameFolder']);
} }
if ($oSettings instanceof Settings) { if ($oSettings instanceof Settings) {
@ -967,11 +967,6 @@ class Actions
} }
} }
if ($oSettingsLocal instanceof Settings) {
$aResult['UseThreads'] = (bool)$oSettingsLocal->GetConf('UseThreads', $aResult['UseThreads']);
$aResult['ReplySameFolder'] = (bool)$oSettingsLocal->GetConf('ReplySameFolder', $aResult['ReplySameFolder']);
}
$aResult['NewMailSounds'] = []; $aResult['NewMailSounds'] = [];
foreach (\glob(APP_VERSION_ROOT_PATH.'static/sounds/*.mp3') as $file) { foreach (\glob(APP_VERSION_ROOT_PATH.'static/sounds/*.mp3') as $file) {
$aResult['NewMailSounds'][] = \basename($file, '.mp3'); $aResult['NewMailSounds'][] = \basename($file, '.mp3');

View file

@ -201,7 +201,27 @@ trait Accounts
public function DoAccountSwitch(): array public function DoAccountSwitch(): array
{ {
if ($this->switchAccount(\trim($this->GetActionParam('Email', '')))) { if ($this->switchAccount(\trim($this->GetActionParam('Email', '')))) {
return $this->DefaultResponse(__FUNCTION__, $this->AppData(false)); $oAccount = $this->getAccountFromToken();
$aResult['Email'] = $oAccount->Email();
$aResult['IncLogin'] = $oAccount->IncLogin();
$aResult['OutLogin'] = $oAccount->OutLogin();
$aResult['AccountHash'] = $oAccount->Hash();
$aResult['ParentEmail'] = $oAccount->ParentEmail();
$aResult['ContactsIsAllowed'] = $this->AddressBookProvider($oAccount)->IsActive();
$oSettingsLocal = $this->SettingsProvider(true)->Load($oAccount);
if ($oSettingsLocal instanceof Settings) {
$aResult['SentFolder'] = (string) $oSettingsLocal->GetConf('SentFolder', '');
$aResult['DraftFolder'] = (string) $oSettingsLocal->GetConf('DraftFolder', '');
$aResult['SpamFolder'] = (string) $oSettingsLocal->GetConf('SpamFolder', '');
$aResult['TrashFolder'] = (string) $oSettingsLocal->GetConf('TrashFolder', '');
$aResult['ArchiveFolder'] = (string) $oSettingsLocal->GetConf('ArchiveFolder', '');
$aResult['HideUnsubscribed'] = (bool) $oSettingsLocal->GetConf('HideUnsubscribed', $aResult['HideUnsubscribed']);
$aResult['UseThreads'] = (bool) $oSettingsLocal->GetConf('UseThreads', $aResult['UseThreads']);
$aResult['ReplySameFolder'] = (bool) $oSettingsLocal->GetConf('ReplySameFolder', $aResult['ReplySameFolder']);
}
// $this->Plugins()->InitAppData($bAdmin, $aResult, $oAccount);
return $this->DefaultResponse(__FUNCTION__, $aResult);
} }
return $this->FalseResponse(__FUNCTION__); return $this->FalseResponse(__FUNCTION__);
} }