mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
refactor(core): remove once signed in event (#6740)
This once signed in event does not work properly.
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
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]);
|
||||
};
|
||||
Reference in New Issue
Block a user