diff --git a/src/components/sidebarLeft/tabs/2fa/index.ts b/src/components/sidebarLeft/tabs/2fa/index.ts index 32890e0c..e2671908 100644 --- a/src/components/sidebarLeft/tabs/2fa/index.ts +++ b/src/components/sidebarLeft/tabs/2fa/index.ts @@ -7,6 +7,7 @@ import Button from "../../../button"; import PopupConfirmAction from "../../../popups/confirmAction"; import SidebarSlider, { SliderSuperTab } from "../../../slider"; import { wrapSticker } from "../../../wrappers"; +import AppSettingsTab from "../settings"; import AppTwoStepVerificationEnterPasswordTab from "./enterPassword"; export default class AppTwoStepVerificationTab extends SliderSuperTab { @@ -67,7 +68,10 @@ export default class AppTwoStepVerificationTab extends SliderSuperTab { const popup = new PopupConfirmAction('popup-disable-password', [{ text: 'DISABLE', callback: () => { - passwordManager.updateSettings({currentPassword: this.plainPassword}); + passwordManager.updateSettings({currentPassword: this.plainPassword}).then(() => { + this.slider.sliceTabsUntilTab(AppSettingsTab, this); + this.close(); + }); }, isDanger: true, }], { diff --git a/src/components/sidebarLeft/tabs/2fa/passwordSet.ts b/src/components/sidebarLeft/tabs/2fa/passwordSet.ts index 5f9357bf..88419395 100644 --- a/src/components/sidebarLeft/tabs/2fa/passwordSet.ts +++ b/src/components/sidebarLeft/tabs/2fa/passwordSet.ts @@ -4,6 +4,7 @@ import appStickersManager from "../../../../lib/appManagers/appStickersManager"; import Button from "../../../button"; import SidebarSlider, { SliderSuperTab } from "../../../slider"; import { wrapSticker } from "../../../wrappers"; +import AppSettingsTab from "../settings"; export default class AppTwoStepVerificationSetTab extends SliderSuperTab { constructor(slider: SidebarSlider) { @@ -49,9 +50,11 @@ export default class AppTwoStepVerificationSetTab extends SliderSuperTab { const btnReturn = Button('btn-primary btn-color-primary', {text: 'RETURN TO SETTINGS'}); attachClickEvent(btnReturn, (e) => { - + this.close(); }); + this.slider.sliceTabsUntilTab(AppSettingsTab, this); + inputWrapper.append(btnReturn); inputContent.append(inputWrapper); diff --git a/src/components/slider.ts b/src/components/slider.ts index d0030e95..62f5b4e9 100644 --- a/src/components/slider.ts +++ b/src/components/slider.ts @@ -2,7 +2,7 @@ import { attachClickEvent } from "../helpers/dom"; import { horizontalMenu } from "./horizontalMenu"; import { TransitionSlider } from "./transition"; import appNavigationController, { NavigationItem } from "./appNavigationController"; -import SliderSuperTab, { SliderTab } from "./sliderTab"; +import SliderSuperTab, { SliderSuperTabConstructable, SliderTab } from "./sliderTab"; const TRANSITION_TIME = 250; @@ -105,6 +105,18 @@ export default class SidebarSlider { this.onCloseTab(id, undefined); } + public sliceTabsUntilTab(tabConstructor: SliderSuperTabConstructable, preserveTab: SliderSuperTab) { + for(let i = this.historyTabIds.length - 1; i >= 0; --i) { + const tab = this.historyTabIds[i]; + if(tab === preserveTab) continue; + else if(tab instanceof tabConstructor) { + break; + } + + this.removeTabFromHistory(tab); + } + } + public onCloseTab(id: number | SliderSuperTab, animate: boolean) { const tab: SliderTab = id instanceof SliderSuperTab ? id : this.tabs.get(id); if(tab) { diff --git a/src/components/sliderTab.ts b/src/components/sliderTab.ts index c50bcedf..e481ec60 100644 --- a/src/components/sliderTab.ts +++ b/src/components/sliderTab.ts @@ -9,6 +9,10 @@ export interface SliderTab { onCloseAfterTimeout?: () => void } +export interface SliderSuperTabConstructable { + new(slider: SidebarSlider, destroyable: boolean): SliderSuperTab; +} + export default class SliderSuperTab implements SliderTab { public container: HTMLElement;