refactor: const userName = await this.authService.getUserName(workspace);

This commit is contained in:
lin onetwo 2023-06-17 13:42:51 +08:00
parent 9514e8dc66
commit 1ff128aaa8
2 changed files with 3 additions and 3 deletions

View file

@ -682,10 +682,10 @@ export class Wiki implements IWikiService {
}
public async restartWiki(workspace: IWorkspace): Promise<void> {
const { id, userName: workspaceUserName, isSubWiki } = workspace;
const { id, isSubWiki } = workspace;
// use workspace specific userName first, and fall back to preferences' userName, pass empty editor username if undefined
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const userName = (workspaceUserName || (await this.authService.get('userName'))) ?? '';
const userName = await this.authService.getUserName(workspace);
this.stopIntervalSync(workspace);
if (!isSubWiki) {

View file

@ -352,7 +352,7 @@ export class WorkspaceView implements IWorkspaceViewService {
const workspace = await this.workspaceService.get(workspaceID);
if (workspace !== undefined) {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const userName = (workspace.userName || (await this.authService.get('userName'))) ?? '';
const userName = await this.authService.getUserName(workspace);
await Promise.all([
this.wikiService.startWiki(workspaceID, userName),
this.viewService.addViewForAllBrowserViews(workspace),