Открыть боковую панель
Teknokomo
universo-react
Коммиты
148e058c
Не подтверждена
Коммит
148e058c
создал
Апр 30, 2024
по автору
EYHN
Просмотр файлов
refactor(core): remove once signed in event (#6740)
This once signed in event does not work properly.
владелец
a14194c4
Изменения
3
Скрыть пробелы
Построчно
Рядом
packages/frontend/core/src/atoms/event.ts
удалено
100644 → 0
Просмотр файла @
a14194c4
import
{
atom
,
useAtom
}
from
'
jotai
'
;
import
{
useCallback
}
from
'
react
'
;
export
type
OnceSignedInEvent
=
()
=>
void
;
export
const
onceSignedInEventsAtom
=
atom
<
OnceSignedInEvent
[]
>
([]);
export
const
setOnceSignedInEventAtom
=
atom
(
null
,
(
get
,
set
,
event
:
OnceSignedInEvent
)
=>
{
set
(
onceSignedInEventsAtom
,
[...
get
(
onceSignedInEventsAtom
),
event
]);
}
);
export
const
useOnceSignedInEvents
=
()
=>
{
const
[
events
,
setEvents
]
=
useAtom
(
onceSignedInEventsAtom
);
return
useCallback
(
async
()
=>
{
try
{
await
Promise
.
all
(
events
.
map
(
event
=>
event
()));
}
catch
(
err
)
{
console
.
error
(
'
Error executing one of the events:
'
,
err
);
}
setEvents
([]);
},
[
events
,
setEvents
]);
};
packages/frontend/core/src/hooks/affine/use-enable-cloud.tsx
Просмотр файла @
148e058c
import
{
useConfirmModal
}
from
'
@affine/component
'
;
import
{
useConfirmModal
}
from
'
@affine/component
'
;
import
{
authAtom
}
from
'
@affine/core/atoms
'
;
import
{
authAtom
}
from
'
@affine/core/atoms
'
;
import
{
setOnceSignedInEventAtom
}
from
'
@affine/core/atoms/event
'
;
import
{
AuthService
}
from
'
@affine/core/modules/cloud
'
;
import
{
AuthService
}
from
'
@affine/core/modules/cloud
'
;
import
{
WorkspaceSubPath
}
from
'
@affine/core/shared
'
;
import
{
WorkspaceSubPath
}
from
'
@affine/core/shared
'
;
import
{
useAFFiNEI18N
}
from
'
@affine/i18n/hooks
'
;
import
{
useAFFiNEI18N
}
from
'
@affine/i18n/hooks
'
;
...
@@ -32,7 +31,6 @@ export const useEnableCloud = () => {
...
@@ -32,7 +31,6 @@ export const useEnableCloud = () => {
const
t
=
useAFFiNEI18N
();
const
t
=
useAFFiNEI18N
();
const
loginStatus
=
useLiveData
(
useService
(
AuthService
).
session
.
status$
);
const
loginStatus
=
useLiveData
(
useService
(
AuthService
).
session
.
status$
);
const
setAuthAtom
=
useSetAtom
(
authAtom
);
const
setAuthAtom
=
useSetAtom
(
authAtom
);
const
setOnceSignedInEvent
=
useSetAtom
(
setOnceSignedInEventAtom
);
const
{
openConfirmModal
,
closeConfirmModal
}
=
useConfirmModal
();
const
{
openConfirmModal
,
closeConfirmModal
}
=
useConfirmModal
();
const
workspacesService
=
useService
(
WorkspacesService
);
const
workspacesService
=
useService
(
WorkspacesService
);
const
{
openPage
}
=
useNavigateHelper
();
const
{
openPage
}
=
useNavigateHelper
();
...
@@ -47,21 +45,15 @@ export const useEnableCloud = () => {
...
@@ -47,21 +45,15 @@ export const useEnableCloud = () => {
[
openPage
,
workspacesService
]
[
openPage
,
workspacesService
]
);
);
const
openSignIn
=
useCallback
(
const
openSignIn
=
useCallback
(()
=>
{
(...
args
:
ConfirmEnableArgs
)
=>
{
setAuthAtom
(
prev
=>
({
...
prev
,
openModal
:
true
}));
setAuthAtom
(
prev
=>
({
...
prev
,
openModal
:
true
}));
},
[
setAuthAtom
]);
setOnceSignedInEvent
(()
=>
{
enableCloud
(...
args
).
catch
(
console
.
error
);
});
},
[
enableCloud
,
setAuthAtom
,
setOnceSignedInEvent
]
);
const
signInOrEnableCloud
=
useCallback
(
const
signInOrEnableCloud
=
useCallback
(
async
(...
args
:
ConfirmEnableArgs
)
=>
{
async
(...
args
:
ConfirmEnableArgs
)
=>
{
// not logged in, open login modal
// not logged in, open login modal
if
(
loginStatus
===
'
unauthenticated
'
)
{
if
(
loginStatus
===
'
unauthenticated
'
)
{
openSignIn
(
...
args
);
openSignIn
();
}
}
if
(
loginStatus
===
'
authenticated
'
)
{
if
(
loginStatus
===
'
authenticated
'
)
{
...
...
packages/frontend/core/src/pages/invite.tsx
Просмотр файла @
148e058c
...
@@ -13,7 +13,6 @@ import type { LoaderFunction } from 'react-router-dom';
...
@@ -13,7 +13,6 @@ import type { LoaderFunction } from 'react-router-dom';
import
{
redirect
,
useLoaderData
}
from
'
react-router-dom
'
;
import
{
redirect
,
useLoaderData
}
from
'
react-router-dom
'
;
import
{
authAtom
}
from
'
../atoms
'
;
import
{
authAtom
}
from
'
../atoms
'
;
import
{
setOnceSignedInEventAtom
}
from
'
../atoms/event
'
;
import
{
RouteLogic
,
useNavigateHelper
}
from
'
../hooks/use-navigate-helper
'
;
import
{
RouteLogic
,
useNavigateHelper
}
from
'
../hooks/use-navigate-helper
'
;
import
{
AuthService
}
from
'
../modules/cloud
'
;
import
{
AuthService
}
from
'
../modules/cloud
'
;
...
@@ -59,8 +58,6 @@ export const Component = () => {
...
@@ -59,8 +58,6 @@ export const Component = () => {
const
{
jumpToSignIn
}
=
useNavigateHelper
();
const
{
jumpToSignIn
}
=
useNavigateHelper
();
const
{
jumpToSubPath
}
=
useNavigateHelper
();
const
{
jumpToSubPath
}
=
useNavigateHelper
();
const
setOnceSignedInEvent
=
useSetAtom
(
setOnceSignedInEventAtom
);
const
setAuthAtom
=
useSetAtom
(
authAtom
);
const
setAuthAtom
=
useSetAtom
(
authAtom
);
const
{
inviteInfo
}
=
useLoaderData
()
as
{
const
{
inviteInfo
}
=
useLoaderData
()
as
{
inviteId
:
string
;
inviteId
:
string
;
...
@@ -78,7 +75,6 @@ export const Component = () => {
...
@@ -78,7 +75,6 @@ export const Component = () => {
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
loginStatus
===
'
unauthenticated
'
&&
!
isRevalidating
)
{
if
(
loginStatus
===
'
unauthenticated
'
&&
!
isRevalidating
)
{
// We can not pass function to navigate state, so we need to save it in atom
// We can not pass function to navigate state, so we need to save it in atom
setOnceSignedInEvent
(
openWorkspace
);
jumpToSignIn
(
jumpToSignIn
(
`/workspace/
${
inviteInfo
.
workspace
.
id
}
/all`
,
`/workspace/
${
inviteInfo
.
workspace
.
id
}
/all`
,
RouteLogic
.
REPLACE
RouteLogic
.
REPLACE
...
@@ -91,7 +87,6 @@ export const Component = () => {
...
@@ -91,7 +87,6 @@ export const Component = () => {
loginStatus
,
loginStatus
,
openWorkspace
,
openWorkspace
,
setAuthAtom
,
setAuthAtom
,
setOnceSignedInEvent
,
]);
]);
if
(
loginStatus
===
'
authenticated
'
)
{
if
(
loginStatus
===
'
authenticated
'
)
{
...
...
Редактирование
Предварительный просмотр
Поддерживает Markdown
0%
Попробовать снова
или
прикрепить новый файл
.
Отмена
You are about to add
0
people
to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать