There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(core): at menu loading state (#9284)
pengx1740b90ef51b4a
diff --git a/packages/frontend/core/src/modules/at-menu-config/services/index.ts b/packages/frontend/core/src/modules/at-menu-config/services/index.tsindex 13456b5dfa..abad2ed75a 100644--- a/packages/frontend/core/src/modules/at-menu-config/services/index.ts+++ b/packages/frontend/core/src/modules/at-menu-config/services/index.ts@@ -1,3 +1,4 @@+import { LoadingIcon } from '@affine/core/blocksuite/presets/blocks/_common/icon';import { fuzzyMatch } from '@affine/core/utils/fuzzy-match';import { I18n, i18nTime } from '@affine/i18n';import track from '@affine/track';@@ -123,6 +124,30 @@ export class AtMenuConfigService extends Service {const showRecent = query.trim().length === 0;(async () => {+ const isIndexerLoading =+ this.docsSearch.indexer.status$.value.remaining !== undefined &&+ this.docsSearch.indexer.status$.value.remaining > 0;++ if (!showRecent && isIndexerLoading) {+ // add a loading item+ docItems.value = [+ {+ key: 'loading',+ name: I18n.t('com.affine.editor.at-menu.loading'),+ icon: LoadingIcon,+ action: () => {+ // no action+ },+ },+ ];+ // wait for indexer to finish+ await this.docsSearch.indexer.status$.waitFor(+ status => status.remaining === 0+ );+ // remove the loading item+ docItems.value = [];+ }+const docMetas = (showRecent? this.recentDocsService.getRecentDocs()diff --git a/packages/frontend/i18n/src/i18n.gen.ts b/packages/frontend/i18n/src/i18n.gen.tsindex 4426958223..17b647a398 100644--- a/packages/frontend/i18n/src/i18n.gen.ts+++ b/packages/frontend/i18n/src/i18n.gen.ts@@ -6299,6 +6299,10 @@ export function useAFFiNEI18N(): {* `Recent`*/["com.affine.editor.at-menu.recent-docs"](): string;+ /**+ * `Loading...`+ */+ ["com.affine.editor.at-menu.recent-docs.loading"](): string;/*** `New`*/diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.jsonindex fd7c4ac659..27a4eb3d58 100644--- a/packages/frontend/i18n/src/resources/en.json+++ b/packages/frontend/i18n/src/resources/en.json@@ -1572,6 +1572,7 @@"com.affine.editor.journal-conflict.title": "Duplicate Entries in Today's Journal","com.affine.editor.at-menu.link-to-doc": "Search for \"{{query}}\"","com.affine.editor.at-menu.recent-docs": "Recent",+ "com.affine.editor.at-menu.loading": "Loading...","com.affine.editor.at-menu.new-doc": "New","com.affine.editor.at-menu.create-page": "New \"{{name}}\" page","com.affine.editor.at-menu.create-edgeless": "New \"{{name}}\" edgeless",