Browse Source

Return to settings after setting password

master
Eduard Kuzmenko 3 years ago
parent
commit
a8ef0206d9
  1. 6
      src/components/sidebarLeft/tabs/2fa/index.ts
  2. 5
      src/components/sidebarLeft/tabs/2fa/passwordSet.ts
  3. 14
      src/components/slider.ts
  4. 4
      src/components/sliderTab.ts

6
src/components/sidebarLeft/tabs/2fa/index.ts

@ -7,6 +7,7 @@ import Button from "../../../button"; @@ -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 { @@ -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,
}], {

5
src/components/sidebarLeft/tabs/2fa/passwordSet.ts

@ -4,6 +4,7 @@ import appStickersManager from "../../../../lib/appManagers/appStickersManager"; @@ -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 { @@ -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);

14
src/components/slider.ts

@ -2,7 +2,7 @@ import { attachClickEvent } from "../helpers/dom"; @@ -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 { @@ -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) {

4
src/components/sliderTab.ts

@ -9,6 +9,10 @@ export interface SliderTab { @@ -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;

Loading…
Cancel
Save