refactor(core): move hooks to core (#5458)

* move @toeverything/hooks -> @affine/core/hooks
* delete @toeverything/hooks

hooks are all business-related logic and are deeply coupled with other parts.

Move them into the core and then reconstruct them by feature.
This commit is contained in:
EYHN
2024-01-02 08:05:46 +00:00
parent 6862b7deaf
commit 4b217e6b89
95 changed files with 99 additions and 347 deletions
@@ -1,3 +1,4 @@
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
import { WorkspaceFlavour, WorkspaceSubPath } from '@affine/env/workspace';
import {
currentWorkspaceAtom,
@@ -5,7 +6,6 @@ import {
workspaceListAtom,
} from '@affine/workspace/atom';
import { assertExists } from '@blocksuite/global/utils';
import { useAsyncCallback } from '@toeverything/hooks/affine-async-hooks';
import { useAtom, useAtomValue } from 'jotai';
import type { ReactElement } from 'react';
import { lazy, Suspense, useCallback } from 'react';
@@ -1,9 +1,8 @@
import '@toeverything/hooks/use-affine-ipc-renderer';
import { pushNotificationAtom } from '@affine/component/notification-center';
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
import { affine } from '@affine/electron-api';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { CLOUD_WORKSPACE_CHANGED_BROADCAST_CHANNEL_KEY } from '@affine/workspace';
import { useAsyncCallback } from '@toeverything/hooks/affine-async-hooks';
import { useAtom, useSetAtom } from 'jotai';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { SessionProvider, useSession } from 'next-auth/react';
@@ -51,7 +50,7 @@ const SessionDefence = (props: PropsWithChildren) => {
});
if (environment.isDesktop) {
window.affine.ipcRenderer.send('affine:login');
affine?.ipcRenderer.send('affine:login');
}
}
prevSession.current = session;