mirror of
https://github.com/bitwarden/browser
synced 2026-02-10 13:40:06 +00:00
Rename inModalMode to modalMode
This commit is contained in:
@@ -73,7 +73,7 @@ export class Fido2PlaceholderComponent implements OnInit, OnDestroy {
|
||||
this.session?.confirmChosenCipher(cipherId);
|
||||
|
||||
await this.router.navigate(["/"]);
|
||||
await this.desktopSettingsService.setInModalMode(false);
|
||||
await this.desktopSettingsService.setModalMode(false);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -103,7 +103,7 @@ export class Fido2PlaceholderComponent implements OnInit, OnDestroy {
|
||||
// The session currently toggles modal on and send us here
|
||||
// But if this route is somehow opened outside of session we want to make sure we clean up?
|
||||
await this.router.navigate(["/"]);
|
||||
await this.desktopSettingsService.setInModalMode(false);
|
||||
await this.desktopSettingsService.setModalMode(false);
|
||||
} catch (error) {
|
||||
// TODO: Handle error appropriately
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export class Fido2PlaceholderComponent implements OnInit, OnDestroy {
|
||||
|
||||
async closeModal() {
|
||||
await this.router.navigate(["/"]);
|
||||
await this.desktopSettingsService.setInModalMode(false);
|
||||
await this.desktopSettingsService.setModalMode(false);
|
||||
|
||||
this.session.notifyConfirmNewCredential(false);
|
||||
// little bit hacky:
|
||||
|
||||
@@ -150,7 +150,7 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
||||
return { cipherId: resultCipherId, userVerified: true };
|
||||
} finally {
|
||||
// Make sure to clean up so the app is never stuck in modal mode?
|
||||
await this.desktopSettingsService.setInModalMode(false);
|
||||
await this.desktopSettingsService.setModalMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,14 +225,14 @@ export class DesktopFido2UserInterfaceSession implements Fido2UserInterfaceSessi
|
||||
return { cipherId: this.createdCipher.id, userVerified: userVerification };
|
||||
} finally {
|
||||
// Make sure to clean up so the app is never stuck in modal mode?
|
||||
await this.desktopSettingsService.setInModalMode(false);
|
||||
await this.desktopSettingsService.setModalMode(false);
|
||||
}
|
||||
}
|
||||
|
||||
private async showUi(route: string, position?: [number, number]): Promise<void> {
|
||||
// Load the UI:
|
||||
// maybe toggling to modal mode shouldn't be done here?
|
||||
await this.desktopSettingsService.setInModalMode(true, position);
|
||||
await this.desktopSettingsService.setModalMode(true, position);
|
||||
await this.router.navigate(["/passkeys"]);
|
||||
}
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ export class Main {
|
||||
async () => {
|
||||
await this.toggleHardwareAcceleration();
|
||||
// Reset modal mode to make sure main window is displayed correctly
|
||||
await this.desktopSettingsService.resetInModalMode();
|
||||
await this.desktopSettingsService.resetModalMode();
|
||||
await this.windowMain.init();
|
||||
await this.i18nService.init();
|
||||
await this.messagingMain.init();
|
||||
|
||||
@@ -77,16 +77,16 @@ export class WindowMain {
|
||||
}
|
||||
});
|
||||
|
||||
this.desktopSettingsService.inModalMode$
|
||||
this.desktopSettingsService.modalMode$
|
||||
.pipe(
|
||||
pairwise(),
|
||||
concatMap(async ([lastValue, newValue]) => {
|
||||
if (lastValue.modalMode && !newValue.modalMode) {
|
||||
if (lastValue.isModalModeActive && !newValue.isModalModeActive) {
|
||||
// Reset the window state to the main window state
|
||||
applyMainWindowStyles(this.win, this.windowStates[mainWindowSizeKey]);
|
||||
// Because modal is used in front of another app, UX wise it makes sense to hide the main window when leaving modal mode.
|
||||
this.win.hide();
|
||||
} else if (!lastValue.modalMode && newValue.modalMode) {
|
||||
} else if (!lastValue.isModalModeActive && newValue.isModalModeActive) {
|
||||
// Apply the popup modal styles
|
||||
this.logService.info("Applying popup modal styles", newValue.modalPosition);
|
||||
applyPopupModalStyles(this.win, newValue.modalPosition);
|
||||
@@ -209,7 +209,7 @@ export class WindowMain {
|
||||
return;
|
||||
}
|
||||
|
||||
await this.desktopSettingsService.setInModalMode(modal);
|
||||
await this.desktopSettingsService.setModalMode(modal);
|
||||
await this.win.loadURL(
|
||||
url.format({
|
||||
protocol: "file:",
|
||||
@@ -405,9 +405,9 @@ export class WindowMain {
|
||||
return;
|
||||
}
|
||||
|
||||
const inModalMode = await firstValueFrom(this.desktopSettingsService.inModalMode$);
|
||||
const modalMode = await firstValueFrom(this.desktopSettingsService.modalMode$);
|
||||
|
||||
if (inModalMode) {
|
||||
if (modalMode.isModalModeActive) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,6 @@ export class WindowState {
|
||||
}
|
||||
|
||||
export class ModalModeState {
|
||||
modalMode: boolean;
|
||||
modalPosition?: [number, number];
|
||||
isModalModeActive: boolean;
|
||||
modalPosition?: [number, number]; // Modal position is often passed from the native UI
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ const MINIMIZE_ON_COPY = new UserKeyDefinition<boolean>(DESKTOP_SETTINGS_DISK, "
|
||||
clearOn: [], // User setting, no need to clear
|
||||
});
|
||||
|
||||
const IN_MODAL_MODE = new KeyDefinition<ModalModeState>(DESKTOP_SETTINGS_DISK, "inModalMode", {
|
||||
const MODAL_MODE = new KeyDefinition<ModalModeState>(DESKTOP_SETTINGS_DISK, "modalMode", {
|
||||
deserializer: (b) => b,
|
||||
});
|
||||
|
||||
@@ -159,9 +159,9 @@ export class DesktopSettingsService {
|
||||
*/
|
||||
minimizeOnCopy$ = this.minimizeOnCopyState.state$.pipe(map(Boolean));
|
||||
|
||||
private readonly inModalModeState = this.stateProvider.getGlobal(IN_MODAL_MODE);
|
||||
private readonly modalModeState = this.stateProvider.getGlobal(MODAL_MODE);
|
||||
|
||||
inModalMode$ = this.inModalModeState.state$;
|
||||
modalMode$ = this.modalModeState.state$;
|
||||
|
||||
constructor(private stateProvider: StateProvider) {
|
||||
this.window$ = this.windowState.state$.pipe(
|
||||
@@ -175,8 +175,8 @@ export class DesktopSettingsService {
|
||||
* This is used to clear the setting on application start to make sure we don't end up
|
||||
* stuck in modal mode if the application is force-closed in modal mode.
|
||||
*/
|
||||
async resetInModalMode() {
|
||||
await this.inModalModeState.update(() => ({ modalMode: false }));
|
||||
async resetModalMode() {
|
||||
await this.modalModeState.update(() => ({ isModalModeActive: false }));
|
||||
}
|
||||
|
||||
async setHardwareAcceleration(enabled: boolean) {
|
||||
@@ -291,7 +291,10 @@ export class DesktopSettingsService {
|
||||
* Sets the modal mode of the application. Setting this changes the windows-size and other properties.
|
||||
* @param value `true` if the application is in modal mode, `false` if it is not.
|
||||
*/
|
||||
async setInModalMode(value: boolean, windowXy?: [number, number]) {
|
||||
await this.inModalModeState.update(() => ({ modalMode: value, modalPosition: windowXy }));
|
||||
async setModalMode(value: boolean, modalPosition?: [number, number]) {
|
||||
await this.modalModeState.update(() => ({
|
||||
isModalModeActive: value,
|
||||
modalPosition: modalPosition,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user