mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 10:06:17 +08:00
feat: add new rule for floating promise (#2726)
Co-authored-by: Himself65 <himself65@outlook.com>
This commit is contained in:
@@ -67,7 +67,7 @@ export class AffineErrorBoundary extends Component<
|
||||
pageId: error.workspace.meta.pageMetas[0].id,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
.finally(() => {
|
||||
this.setState({ error: null });
|
||||
});
|
||||
}}
|
||||
|
||||
@@ -95,7 +95,7 @@ export const WorkspaceSettingDetail: React.FC<
|
||||
const workspaceId = workspace.id;
|
||||
useEffect(() => {
|
||||
if (isAffine && isOwner) {
|
||||
preload([QueryKey.getMembers, workspaceId], fetcher);
|
||||
preload([QueryKey.getMembers, workspaceId], fetcher).catch(console.error);
|
||||
}
|
||||
}, [isAffine, isOwner, workspaceId]);
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
|
||||
@@ -46,8 +46,8 @@ const PublishPanelAffine: React.FC<PublishPanelAffineProps> = ({
|
||||
const shareUrl = origin + '/public-workspace/' + workspace.id;
|
||||
const t = useAFFiNEI18N();
|
||||
const publishWorkspace = useToggleWorkspacePublish(workspace);
|
||||
const copyUrl = useCallback(() => {
|
||||
navigator.clipboard.writeText(shareUrl);
|
||||
const copyUrl = useCallback(async () => {
|
||||
await navigator.clipboard.writeText(shareUrl);
|
||||
toast(t['Copied link to clipboard']());
|
||||
}, [shareUrl, t]);
|
||||
|
||||
|
||||
@@ -16,12 +16,12 @@ export const usePageHelper = (blockSuiteWorkspace: BlockSuiteWorkspace) => {
|
||||
|
||||
const createPageAndOpen = () => {
|
||||
const page = createPage();
|
||||
openPage(blockSuiteWorkspace.id, page.id);
|
||||
return openPage(blockSuiteWorkspace.id, page.id);
|
||||
};
|
||||
const createEdgelessAndOpen = () => {
|
||||
const page = createPage();
|
||||
setPreferredMode(page.id, 'edgeless');
|
||||
openPage(blockSuiteWorkspace.id, page.id);
|
||||
return openPage(blockSuiteWorkspace.id, page.id);
|
||||
};
|
||||
const importFileAndOpen = async () => {
|
||||
const { showImportModal } = await import('@blocksuite/blocks');
|
||||
|
||||
+3
-1
@@ -10,7 +10,9 @@ export const EditPage = () => {
|
||||
const { jumpToPage } = useRouterHelper(router);
|
||||
const onClickPage = useCallback(() => {
|
||||
if (workspaceId && pageId) {
|
||||
jumpToPage(workspaceId, pageId);
|
||||
jumpToPage(workspaceId, pageId).catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
}, [jumpToPage, pageId, workspaceId]);
|
||||
return (
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ const LanguageMenuContent: FC = () => {
|
||||
const i18n = useI18N();
|
||||
const changeLanguage = useCallback(
|
||||
(event: string) => {
|
||||
i18n.changeLanguage(event);
|
||||
void i18n.changeLanguage(event);
|
||||
},
|
||||
[i18n]
|
||||
);
|
||||
|
||||
+2
-2
@@ -96,8 +96,8 @@ const LocalHeaderShareMenu: React.FC<BaseHeaderProps> = props => {
|
||||
onClose={() => {
|
||||
setOpen(false);
|
||||
}}
|
||||
onConform={() => {
|
||||
onTransformWorkspace(
|
||||
onConform={async () => {
|
||||
await onTransformWorkspace(
|
||||
WorkspaceFlavour.LOCAL,
|
||||
WorkspaceFlavour.AFFINE,
|
||||
props.workspace as LocalWorkspace
|
||||
|
||||
+7
-10
@@ -138,17 +138,14 @@ export const SyncUser = () => {
|
||||
workspace as LocalWorkspace
|
||||
);
|
||||
// fixme(himself65): refactor this
|
||||
router
|
||||
.replace({
|
||||
pathname: `/workspace/[workspaceId]/all`,
|
||||
query: {
|
||||
workspaceId: id,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
router.reload();
|
||||
});
|
||||
await router.replace({
|
||||
pathname: `/workspace/[workspaceId]/all`,
|
||||
query: {
|
||||
workspaceId: id,
|
||||
},
|
||||
});
|
||||
setOpen(false);
|
||||
router.reload();
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
|
||||
+3
-2
@@ -63,9 +63,10 @@ export const TrashButtonGroup = () => {
|
||||
workspaceId: workspace.id,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
blockSuiteWorkspace.removePage(pageId);
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
blockSuiteWorkspace.removePage(pageId);
|
||||
}}
|
||||
onCancel={() => {
|
||||
setOpen(false);
|
||||
|
||||
@@ -43,7 +43,7 @@ export const MessageCenter: FC = memo(function MessageCenter() {
|
||||
})
|
||||
.catch(() => {
|
||||
setPopup(false);
|
||||
onLogout();
|
||||
return onLogout();
|
||||
});
|
||||
} else {
|
||||
toast(Messages[event.detail.code].message);
|
||||
|
||||
@@ -64,9 +64,11 @@ export const PublishedResults: FC<PublishedResultsProps> = ({
|
||||
<Command.Item
|
||||
key={result.id}
|
||||
onSelect={() => {
|
||||
router.push(
|
||||
`/public-workspace/${router.query.workspaceId}/${result.id}`
|
||||
);
|
||||
router
|
||||
.push(
|
||||
`/public-workspace/${router.query.workspaceId}/${result.id}`
|
||||
)
|
||||
.catch(err => console.error(err));
|
||||
onClose();
|
||||
}}
|
||||
value={result.id}
|
||||
|
||||
@@ -71,7 +71,9 @@ export const Results: FC<ResultsProps> = ({
|
||||
value={page.id}
|
||||
onSelect={() => {
|
||||
onClose();
|
||||
jumpToPage(blockSuiteWorkspace.id, page.id);
|
||||
jumpToPage(blockSuiteWorkspace.id, page.id).catch(
|
||||
console.error
|
||||
);
|
||||
}}
|
||||
>
|
||||
<StyledListItem>
|
||||
@@ -95,7 +97,7 @@ export const Results: FC<ResultsProps> = ({
|
||||
value={link.title}
|
||||
onSelect={() => {
|
||||
onClose();
|
||||
router.push(link.href);
|
||||
router.push(link.href).catch(console.error);
|
||||
}}
|
||||
>
|
||||
<StyledListItem>
|
||||
@@ -133,7 +135,9 @@ export const Results: FC<ResultsProps> = ({
|
||||
onSelect={() => {
|
||||
onClose();
|
||||
assertExists(blockSuiteWorkspace.id);
|
||||
jumpToPage(blockSuiteWorkspace.id, result.id);
|
||||
jumpToPage(blockSuiteWorkspace.id, result.id).catch(error =>
|
||||
console.error(error)
|
||||
);
|
||||
}}
|
||||
value={result.id}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user