Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): at menu loading state #9284

Merged
merged 1 commit into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions packages/frontend/i18n/src/i18n.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
*/
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/i18n/src/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading