fix: add @typescript-eslint/no-floating-promises rule (#2764)

Co-authored-by: himself65 <himself65@outlook.com>
(cherry picked from commit 1c8f1a05d0)
This commit is contained in:
LongYinan
2023-06-13 14:55:23 +08:00
committed by Alex Yang
parent 72ef788927
commit ef7fd194c4
25 changed files with 342 additions and 239 deletions
@@ -49,7 +49,9 @@ export const updateAvailableAtom = atomWithObservable(() => {
return rpcToObservable(null as any | null, {
event: window.events?.updater.onUpdateAvailable,
onSubscribe: () => {
window.apis?.updater.checkForUpdatesAndNotify();
window.apis?.updater.checkForUpdatesAndNotify().catch(err => {
console.error(err);
});
},
});
});
@@ -65,7 +65,10 @@ export function AppUpdaterButton({ className, style }: AddPageButtonProps) {
}, [currentVersion, setChangelogCheckAtom]);
const onClickUpdate = useCallback(() => {
if (updateReady) {
window.apis?.updater.quitAndInstall();
window.apis?.updater.quitAndInstall().catch(err => {
// TODO: add error toast here
console.error(err);
});
} else if (updateAvailable) {
if (updateAvailable.allowAutoUpdate) {
// wait for download to finish
@@ -9,8 +9,15 @@ export const CopyLink = ({ onItemClick, onSelect }: CommonMenuItemProps) => {
const t = useAFFiNEI18N();
const copyUrl = useCallback(() => {
navigator.clipboard.writeText(window.location.href);
toast(t['Copied link to clipboard']());
navigator.clipboard
.writeText(window.location.href)
.then(() => {
toast(t['Copied link to clipboard']());
})
.catch(err => {
// TODO add error toast here
console.error(err);
});
}, [t]);
return (
@@ -35,8 +35,13 @@ const ExportToPdfMenuItem = ({
if (result !== undefined) {
return;
}
contentParser.exportPdf();
return contentParser.exportPdf();
})
.then(() => {
onSelect?.({ type: 'pdf' });
})
.catch(err => {
console.error(err);
});
}, [currentEditor, onSelect]);
if (currentEditor && currentEditor.mode === 'page') {
@@ -66,7 +71,9 @@ const ExportToHtmlMenuItem = ({
if (!contentParserRef.current) {
contentParserRef.current = new ContentParser(currentEditor.page);
}
contentParserRef.current.exportHtml();
contentParserRef.current.exportHtml().catch(err => {
console.error(err);
});
onSelect?.({ type: 'html' });
}, [onSelect, currentEditor]);
return (
@@ -123,7 +130,9 @@ const ExportToMarkdownMenuItem = ({
if (!contentParserRef.current) {
contentParserRef.current = new ContentParser(currentEditor.page);
}
contentParserRef.current.exportMarkdown();
contentParserRef.current.exportMarkdown().catch(err => {
console.error(err);
});
onSelect?.({ type: 'markdown' });
}, [onSelect, currentEditor]);
return (
@@ -10,7 +10,11 @@ const DesktopThemeSync = memo(function DesktopThemeSync() {
const onceRef = useRef(false);
if (lastThemeRef.current !== theme || !onceRef.current) {
if (environment.isDesktop && theme) {
window.apis?.ui.handleThemeChange(theme as 'dark' | 'light' | 'system');
window.apis?.ui
.handleThemeChange(theme as 'dark' | 'light' | 'system')
.catch(err => {
console.error(err);
});
}
lastThemeRef.current = theme;
onceRef.current = true;
+14 -9
View File
@@ -32,15 +32,20 @@ export function definePlugin<ID extends string>(
if (isServer) {
if (serverAdapter) {
serverAdapter.load().then(({ default: adapter }) => {
rootStore.set(affinePluginsAtom, plugins => ({
...plugins,
[definition.id]: {
...basePlugin,
serverAdapter: adapter,
},
}));
});
serverAdapter
.load()
.then(({ default: adapter }) => {
rootStore.set(affinePluginsAtom, plugins => ({
...plugins,
[definition.id]: {
...basePlugin,
serverAdapter: adapter,
},
}));
})
.catch(err => {
console.error(err);
});
}
} else if (isClient) {
if (blockSuiteAdapter) {
+4 -2
View File
@@ -171,7 +171,9 @@ const createSQLiteProvider = (
if (origin === sqliteOrigin) {
return;
}
apis.db.applyDocUpdate(blockSuiteWorkspace.id, update);
apis.db.applyDocUpdate(blockSuiteWorkspace.id, update).catch(err => {
console.error(err);
});
}
let unsubscribe = () => {};
@@ -247,7 +249,7 @@ const createSQLiteDBDownloadProvider = (
const diff = Y.encodeStateAsUpdate(blockSuiteWorkspace.doc, updates);
// also apply updates to sqlite
apis.db.applyDocUpdate(blockSuiteWorkspace.id, diff);
await apis.db.applyDocUpdate(blockSuiteWorkspace.id, diff);
const bs = blockSuiteWorkspace.blobs;