mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-04-27 15:50:57 -07:00
parent
681ab1ae0e
commit
753dfc83ab
3 changed files with 14 additions and 15 deletions
|
|
@ -264,7 +264,7 @@ export class View implements IViewService {
|
|||
}
|
||||
|
||||
public async getSharedWebPreferences(workspace: IWorkspace) {
|
||||
const preferences = await this.preferenceService.getPreferences();
|
||||
const preferences = this.preferenceService.getPreferences();
|
||||
const { spellcheck } = preferences;
|
||||
|
||||
const sessionOfView = setupViewSession(workspace, preferences);
|
||||
|
|
@ -330,7 +330,7 @@ export class View implements IViewService {
|
|||
}
|
||||
|
||||
public async loadUrlForView(workspace: IWorkspace, view: BrowserView, uri?: string): Promise<void> {
|
||||
const { rememberLastPageVisited } = await this.preferenceService.getPreferences();
|
||||
const { rememberLastPageVisited } = this.preferenceService.getPreferences();
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, @typescript-eslint/strict-boolean-expressions
|
||||
const urlToLoad = uri || (rememberLastPageVisited ? workspace.lastUrl : workspace.homeUrl) || workspace.homeUrl || getDefaultTidGiUrl(workspace.id);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ export class Window implements IWindowService {
|
|||
}
|
||||
|
||||
public async close(windowName: WindowNames): Promise<void> {
|
||||
this.get(windowName)?.close();
|
||||
this.get(windowName)?.close?.();
|
||||
if (windowName === WindowNames.menuBar) {
|
||||
// keep the menubar window instance
|
||||
this.mainWindowMenuBar?.app?.hide?.();
|
||||
|
|
@ -157,7 +157,7 @@ export class Window implements IWindowService {
|
|||
}
|
||||
|
||||
// create new window
|
||||
const { hideMenuBar: autoHideMenuBar, titleBar: showTitleBar, menuBarAlwaysOnTop, alwaysOnTop } = await this.preferenceService.getPreferences();
|
||||
const { hideMenuBar: autoHideMenuBar, titleBar: showTitleBar, menuBarAlwaysOnTop, alwaysOnTop } = this.preferenceService.getPreferences();
|
||||
let windowWithBrowserViewConfig: Partial<BrowserWindowConstructorOptions> = {};
|
||||
let windowWithBrowserViewState: windowStateKeeperState | undefined;
|
||||
const WindowToKeepPositionState = [WindowNames.main, WindowNames.menuBar];
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export function registerBrowserViewWindowListeners(newWindow: BrowserWindow, win
|
|||
if (swipeToNavigate) {
|
||||
if (newWindow === undefined) return;
|
||||
newWindow.on('swipe', (_event, direction) => {
|
||||
const view = newWindow?.getBrowserView();
|
||||
const view = newWindow?.getBrowserView?.();
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
if (view) {
|
||||
if (direction === 'left') {
|
||||
|
|
@ -31,8 +31,9 @@ export function registerBrowserViewWindowListeners(newWindow: BrowserWindow, win
|
|||
});
|
||||
// Hide window instead closing on macos
|
||||
newWindow.on('close', async (event) => {
|
||||
// only do this for main window
|
||||
if (windowName !== WindowNames.main || newWindow === undefined) return;
|
||||
const windowMeta = await windowService.getWindowMeta(WindowNames.main);
|
||||
if (newWindow === undefined) return;
|
||||
if (isMac && windowMeta?.forceClose !== true) {
|
||||
event.preventDefault();
|
||||
// https://github.com/electron/electron/issues/6033#issuecomment-242023295
|
||||
|
|
@ -50,22 +51,20 @@ export function registerBrowserViewWindowListeners(newWindow: BrowserWindow, win
|
|||
});
|
||||
|
||||
newWindow.on('focus', () => {
|
||||
if (newWindow === undefined) return;
|
||||
const view = newWindow?.getBrowserView();
|
||||
if (windowName !== WindowNames.main || newWindow === undefined) return;
|
||||
const view = newWindow?.getBrowserView?.();
|
||||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
||||
view?.webContents?.focus();
|
||||
view?.webContents?.focus?.();
|
||||
});
|
||||
|
||||
newWindow.on('enter-full-screen', async () => {
|
||||
const mainWindow = windowService.get(windowName);
|
||||
if (mainWindow === undefined) return;
|
||||
mainWindow?.webContents?.send?.('is-fullscreen-updated', true);
|
||||
if (windowName !== WindowNames.main || newWindow === undefined) return;
|
||||
newWindow?.webContents?.send?.('is-fullscreen-updated', true);
|
||||
await workspaceViewService.realignActiveWorkspace();
|
||||
});
|
||||
newWindow.on('leave-full-screen', async () => {
|
||||
const mainWindow = windowService.get(windowName);
|
||||
if (mainWindow === undefined) return;
|
||||
mainWindow?.webContents?.send?.('is-fullscreen-updated', false);
|
||||
if (windowName !== WindowNames.main || newWindow === undefined) return;
|
||||
newWindow?.webContents?.send?.('is-fullscreen-updated', false);
|
||||
await workspaceViewService.realignActiveWorkspace();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue