refactor: make most of methods async so we don't need AsyncifyProxy

This commit is contained in:
tiddlygit-test 2021-04-23 22:09:31 +08:00
parent 19a06ac559
commit 7405e7a36f
24 changed files with 164 additions and 154 deletions

View file

@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable unicorn/consistent-destructuring */
import { app, session, dialog } from 'electron';
import { injectable } from 'inversify';
@ -38,9 +39,9 @@ export class WorkspaceView implements IWorkspaceViewService {
const workspaces = this.workspaceService.getWorkspaces();
for (const workspaceID in workspaces) {
const workspace = workspaces[workspaceID];
if ((this.preferenceService.get('hibernateUnusedWorkspacesAtLaunch') || workspace.hibernateWhenUnused) && !workspace.active) {
if (((await this.preferenceService.get('hibernateUnusedWorkspacesAtLaunch')) || workspace.hibernateWhenUnused) && !workspace.active) {
if (!workspace.hibernated && !workspace.isSubWiki) {
this.workspaceService.update(workspaceID, { hibernated: true });
await this.workspaceService.update(workspaceID, { hibernated: true });
}
return;
}
@ -245,7 +246,7 @@ export class WorkspaceView implements IWorkspaceViewService {
* Seems this is for relocating BrowserView in the electron window
* // TODO: why we need this?
*/
public realignActiveWorkspace(): void {
public async realignActiveWorkspace(): Promise<void> {
// this function only call browserView.setBounds
// do not attempt to recall browserView.webContents.focus()
// as it breaks page focus (cursor, scroll bar not visible)
@ -258,7 +259,7 @@ export class WorkspaceView implements IWorkspaceViewService {
const activeWorkspace = this.workspaceService.getActiveWorkspace();
const mainWindow = this.windowService.get(WindowNames.main);
if (activeWorkspace !== undefined && mainWindow !== undefined) {
this.viewService.realignActiveView(mainWindow, activeWorkspace.id);
void this.viewService.realignActiveView(mainWindow, activeWorkspace.id);
}
}
}

View file

@ -23,7 +23,7 @@ export interface IWorkspaceViewService {
* @param id workspace id, if omit, will load url in active workspace if existed
*/
loadURL(url: string, id?: string): Promise<void>;
realignActiveWorkspace(): void;
realignActiveWorkspace(): Promise<void>;
openUrlInWorkspace(url: string, id: string): Promise<void>;
}
export const WorkspaceViewServiceIPCDescriptor = {