diff --git a/src/components/sidebarLeft/tabs/editFolder.ts b/src/components/sidebarLeft/tabs/editFolder.ts index 9aa07512..b6649d16 100644 --- a/src/components/sidebarLeft/tabs/editFolder.ts +++ b/src/components/sidebarLeft/tabs/editFolder.ts @@ -8,6 +8,7 @@ import { ripple } from "../../ripple"; import { SliderTab } from "../../slider"; import { toast } from "../../toast"; import appMessagesManager from "../../../lib/appManagers/appMessagesManager"; +import { CLICK_EVENT_NAME } from "../../../helpers/dom"; const MAX_FOLDER_NAME_LENGTH = 12; @@ -71,7 +72,7 @@ export default class AppEditFolderTab implements SliderTab { this.animation = player; }); - this.deleteFolderBtn.addEventListener('click', () => { + this.deleteFolderBtn.addEventListener(CLICK_EVENT_NAME, () => { this.deleteFolderBtn.setAttribute('disabled', 'true'); appMessagesManager.filtersStorage.updateDialogFilter(this.filter, true).then(bool => { if(bool) { diff --git a/src/components/sidebarLeft/tabs/settings.ts b/src/components/sidebarLeft/tabs/settings.ts index 4735d3ea..7ed1e242 100644 --- a/src/components/sidebarLeft/tabs/settings.ts +++ b/src/components/sidebarLeft/tabs/settings.ts @@ -5,6 +5,7 @@ import { parseMenuButtonsTo } from "../../misc"; import apiManager from "../../../lib/mtproto/mtprotoworker"; import appSidebarLeft, { AppSidebarLeft } from ".."; import appUsersManager from "../../../lib/appManagers/appUsersManager"; +import { CLICK_EVENT_NAME } from "../../../helpers/dom"; export default class AppSettingsTab implements SliderTab { private container = document.querySelector('.settings-container') as HTMLDivElement; @@ -30,7 +31,7 @@ export default class AppSettingsTab implements SliderTab { this.fillElements(); }); */ - this.logOutBtn.addEventListener('click', (e) => { + this.logOutBtn.addEventListener(CLICK_EVENT_NAME, (e) => { apiManager.logOut(); }); diff --git a/src/lib/mtproto/apiManager.ts b/src/lib/mtproto/apiManager.ts index 96d037d6..775eaf11 100644 --- a/src/lib/mtproto/apiManager.ts +++ b/src/lib/mtproto/apiManager.ts @@ -131,18 +131,26 @@ export class ApiManager { logoutPromises.push(this.invokeApi('auth.logOut', {}, {dcId: i + 1, ignoreErrors: true})); } } - - return Promise.all(logoutPromises).then(() => { - }, (error) => { - error.handled = true; - }).finally(() => { + + const clear = () => { + //console.error('apiManager: logOut clear'); + this.baseDcId = 0; //this.telegramMeNotify(false); const promise = AppStorage.clear(); promise.finally(() => { self.postMessage({type: 'reload'}); }); - })/* .then(() => { + }; + + setTimeout(clear, 1e3); + + //return; + + return Promise.all(logoutPromises).then(() => { + }, (error) => { + error.handled = true; + }).finally(clear)/* .then(() => { location.pathname = '/'; }) */; }