ci(core): eslint errors for core (#4662)

This commit is contained in:
Joooye_34
2023-11-10 18:25:59 +08:00
committed by GitHub
parent b98a258083
commit 30bac7dce2
44 changed files with 264 additions and 140 deletions
@@ -1,5 +1,6 @@
import { LOCALES, useI18N } from '@affine/i18n';
import { useCallback, useMemo } from 'react';
import { useAsyncCallback } from '@toeverything/hooks/affine-async-hooks';
import { useMemo } from 'react';
export function useLanguageHelper() {
const i18n = useI18N();
@@ -16,9 +17,9 @@ export function useLanguageHelper() {
})),
[]
);
const onLanguageChange = useCallback(
(event: string) => {
i18n.changeLanguage(event);
const onLanguageChange = useAsyncCallback(
async (event: string) => {
await i18n.changeLanguage(event);
},
[i18n]
);
@@ -117,8 +117,8 @@ export function useRegisterBlocksuiteEditorCommands(
category: `editor:${mode}`,
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
label: t['Export to PDF'](),
run() {
exportHandler('pdf');
async run() {
await exportHandler('pdf');
},
})
);
@@ -130,8 +130,8 @@ export function useRegisterBlocksuiteEditorCommands(
category: `editor:${mode}`,
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
label: t['Export to HTML'](),
run() {
exportHandler('html');
async run() {
await exportHandler('html');
},
})
);
@@ -143,8 +143,8 @@ export function useRegisterBlocksuiteEditorCommands(
category: `editor:${mode}`,
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
label: t['Export to PNG'](),
run() {
exportHandler('png');
async run() {
await exportHandler('png');
},
})
);
@@ -156,8 +156,8 @@ export function useRegisterBlocksuiteEditorCommands(
category: `editor:${mode}`,
icon: mode === 'page' ? <PageIcon /> : <EdgelessIcon />,
label: t['Export to Markdown'](),
run() {
exportHandler('markdown');
async run() {
await exportHandler('markdown');
},
})
);
@@ -7,10 +7,10 @@ import {
rootWorkspacesMetadataAtom,
workspaceAdaptersAtom,
} from '@affine/workspace/atom';
import { useAsyncCallback } from '@toeverything/hooks/affine-async-hooks';
import { currentPageIdAtom } from '@toeverything/infra/atom';
import { WorkspaceVersion } from '@toeverything/infra/blocksuite';
import { useAtomValue, useSetAtom } from 'jotai';
import { useCallback } from 'react';
import { openSettingModalAtom } from '../../atoms';
import { useNavigateHelper } from '../use-navigate-helper';
@@ -24,7 +24,7 @@ export function useOnTransformWorkspace() {
const currentPageId = useAtomValue(currentPageIdAtom);
const pushNotification = useSetAtom(pushNotificationAtom);
return useCallback(
return useAsyncCallback(
async <From extends WorkspaceFlavour, To extends WorkspaceFlavour>(
from: From,
to: To,
@@ -1,6 +1,6 @@
import { type SubscriptionQuery, subscriptionQuery } from '@affine/graphql';
import { useQuery } from '@affine/workspace/affine/gql';
import { useCallback } from 'react';
import { useAsyncCallback } from '@toeverything/hooks/affine-async-hooks';
export type Subscription = NonNullable<
NonNullable<SubscriptionQuery['currentUser']>['subscription']
@@ -16,9 +16,9 @@ export const useUserSubscription = () => {
query: subscriptionQuery,
});
const set: SubscriptionMutator = useCallback(
(update?: Partial<Subscription>) => {
mutate(prev => {
const set: SubscriptionMutator = useAsyncCallback(
async (update?: Partial<Subscription>) => {
await mutate(prev => {
if (!update || !prev?.currentUser?.subscription) {
return;
}