mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix: sigin in different window may not refresh workspace list (#4270)
Co-authored-by: Alex Yang <himself65@outlook.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import path from 'node:path';
|
||||
|
||||
import type { App } from 'electron';
|
||||
import { type App, type BrowserWindow, ipcMain } from 'electron';
|
||||
|
||||
import { buildType, CLOUD_BASE_URL, isDev } from './config';
|
||||
import { logger } from './logger';
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
restoreOrCreateWindow,
|
||||
setCookie,
|
||||
} from './main-window';
|
||||
import { uiSubjects } from './ui';
|
||||
|
||||
let protocol = buildType === 'stable' ? 'affine' : `affine-${buildType}`;
|
||||
if (isDev) {
|
||||
@@ -100,16 +99,16 @@ async function handleOauthJwt(url: string) {
|
||||
isSecure ? '__Secure-next-auth.callback-url' : 'next-auth.callback-url'
|
||||
);
|
||||
|
||||
let hiddenWindow: BrowserWindow | null = null;
|
||||
|
||||
ipcMain.once('affine:login', () => {
|
||||
hiddenWindow?.destroy();
|
||||
});
|
||||
|
||||
// hacks to refresh auth state in the main window
|
||||
const window = await handleOpenUrlInHiddenWindow(
|
||||
hiddenWindow = await handleOpenUrlInHiddenWindow(
|
||||
mainWindowOrigin + '/auth/signIn'
|
||||
);
|
||||
uiSubjects.onFinishLogin.next({
|
||||
success: true,
|
||||
});
|
||||
setTimeout(() => {
|
||||
window.destroy();
|
||||
}, 3000);
|
||||
} catch (e) {
|
||||
logger.error('failed to open url in popup', e);
|
||||
}
|
||||
|
||||
@@ -5,20 +5,6 @@ import { uiSubjects } from './subject';
|
||||
* Events triggered by application menu
|
||||
*/
|
||||
export const uiEvents = {
|
||||
onFinishLogin: (
|
||||
fn: (result: { success: boolean; email?: string }) => void
|
||||
) => {
|
||||
const sub = uiSubjects.onFinishLogin.subscribe(fn);
|
||||
return () => {
|
||||
sub.unsubscribe();
|
||||
};
|
||||
},
|
||||
onStartLogin: (fn: (opts: { email?: string }) => void) => {
|
||||
const sub = uiSubjects.onStartLogin.subscribe(fn);
|
||||
return () => {
|
||||
sub.unsubscribe();
|
||||
};
|
||||
},
|
||||
onMaximized: (fn: (maximized: boolean) => void) => {
|
||||
const sub = uiSubjects.onMaximized.subscribe(fn);
|
||||
return () => {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
export const uiSubjects = {
|
||||
onStartLogin: new Subject<{ email?: string }>(),
|
||||
onFinishLogin: new Subject<{ success: boolean; email?: string }>(),
|
||||
onMaximized: new Subject<boolean>(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user