Skip to content

Commit

Permalink
feat(core): tag groups sorted alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmFly committed May 10, 2024
1 parent 931e996 commit 09a78ef
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TagService } from '@affine/core/modules/tag';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { FavoritedIcon, FavoriteIcon } from '@blocksuite/icons';
import type { DocMeta } from '@blocksuite/store';
import { useLiveData, useService } from '@toeverything/infra';
import { LiveData, useLiveData, useService } from '@toeverything/infra';
import { type ReactNode, useMemo } from 'react';

import * as styles from './group-definitions.css';
Expand Down Expand Up @@ -128,7 +128,17 @@ const GroupTagLabel = ({ tag, count }: { tag: Tag; count: number }) => {
};
export const useTagGroupDefinitions = (): ItemGroupDefinition<ListItem>[] => {
const tagList = useService(TagService).tagList;
const tags = useLiveData(tagList.tags$);
const sortedTagsLiveData$ = useMemo(
() =>
LiveData.computed(get =>
get(tagList.tags$).sort((a, b) =>
get(a.value$).localeCompare(get(b.value$))
)
),
[tagList.tags$]
);
const tags = useLiveData(sortedTagsLiveData$);

const t = useAFFiNEI18N();

const untagged = useMemo(
Expand Down

0 comments on commit 09a78ef

Please sign in to comment.