refactor: move authInfo check to initializeWorkspaceView

This commit is contained in:
tiddlygit-test 2021-07-24 19:10:49 +08:00
parent 42ae2a61de
commit 3a0e96f9eb
2 changed files with 13 additions and 13 deletions

View file

@ -197,19 +197,6 @@ export class View implements IViewService {
const { rememberLastPageVisited, shareWorkspaceBrowsingData, spellcheck, spellcheckLanguages } = await this.preferenceService.getPreferences();
// configure session, proxy & ad blocker
const partitionId = shareWorkspaceBrowsingData ? 'persist:shared' : `persist:${workspace.id}`;
if (workspace.storageService !== SupportedStorageServices.local) {
const userInfo = this.authService.getStorageServiceUserInfo(workspace.storageService);
if (userInfo === undefined) {
// user not login into Github or something else
void dialog.showMessageBox(browserWindow, {
title: i18n.t('Dialog.StorageServiceUserInfoNoFound'),
message: i18n.t('Dialog.StorageServiceUserInfoNoFoundDetail'),
buttons: ['OK'],
cancelId: 0,
defaultId: 0,
});
}
}
// prepare configs for start a BrowserView that loads wiki's web content
// session
const sessionOfView = session.fromPartition(partitionId);

View file

@ -59,6 +59,19 @@ export class WorkspaceView implements IWorkspaceViewService {
if (mainWindow === undefined) {
throw new Error(i18n.t(`Error.MainWindowMissing`));
}
if (workspace.storageService !== SupportedStorageServices.local) {
const userInfo = this.authService.getStorageServiceUserInfo(workspace.storageService);
if (userInfo === undefined) {
// user not login into Github or something else
void dialog.showMessageBox(mainWindow, {
title: i18n.t('Dialog.StorageServiceUserInfoNoFound'),
message: i18n.t('Dialog.StorageServiceUserInfoNoFoundDetail'),
buttons: ['OK'],
cancelId: 0,
defaultId: 0,
});
}
}
await this.wikiService.wikiStartup(workspace);
const userInfo = await this.authService.getStorageServiceUserInfo(workspace.storageService);