mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
@@ -1,6 +1,6 @@
|
||||
import { toast } from '@affine/component';
|
||||
import { CollectionService } from '@affine/core/modules/collection';
|
||||
import { FavoriteItemsAdapter } from '@affine/core/modules/properties';
|
||||
import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/properties';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { useLiveData, useService, WorkspaceService } from '@toeverything/infra';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
@@ -16,7 +16,7 @@ import { VirtualizedList } from '../virtualized-list';
|
||||
|
||||
const FavoriteOperation = ({ collection }: { collection: ListItem }) => {
|
||||
const t = useI18n();
|
||||
const favAdapter = useService(FavoriteItemsAdapter);
|
||||
const favAdapter = useService(CompatibleFavoriteItemsAdapter);
|
||||
const isFavorite = useLiveData(
|
||||
favAdapter.isFavorite$(collection.id, 'collection')
|
||||
);
|
||||
|
||||
@@ -211,16 +211,14 @@ export const PageOperationCell = ({
|
||||
);
|
||||
return (
|
||||
<>
|
||||
{runtimeConfig.enableNewFavorite && (
|
||||
<ColWrapper
|
||||
hideInSmallContainer
|
||||
data-testid="page-list-item-favorite"
|
||||
data-favorite={favourite ? true : undefined}
|
||||
className={styles.favoriteCell}
|
||||
>
|
||||
<FavoriteTag onClick={onToggleFavoritePage} active={favourite} />
|
||||
</ColWrapper>
|
||||
)}
|
||||
<ColWrapper
|
||||
hideInSmallContainer
|
||||
data-testid="page-list-item-favorite"
|
||||
data-favorite={favourite ? true : undefined}
|
||||
className={styles.favoriteCell}
|
||||
>
|
||||
<FavoriteTag onClick={onToggleFavoritePage} active={favourite} />
|
||||
</ColWrapper>
|
||||
<ColWrapper alignment="start">
|
||||
<Menu
|
||||
items={OperationMenu}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { toast } from '@affine/component';
|
||||
import { FavoriteService } from '@affine/core/modules/favorite';
|
||||
import { TagService } from '@affine/core/modules/tag';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { useLiveData, useService, WorkspaceService } from '@toeverything/infra';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
import { FavoriteTag } from '../components/favorite-tag';
|
||||
import { tagHeaderColsDef } from '../header-col-def';
|
||||
import { TagListItemRenderer } from '../page-group';
|
||||
import { ListTableHeader } from '../page-header';
|
||||
@@ -11,32 +14,29 @@ import { SelectorLayout } from '../selector/selector-layout';
|
||||
import type { ListItem, TagMeta } from '../types';
|
||||
import { VirtualizedList } from '../virtualized-list';
|
||||
|
||||
// TODO(@EYHN): add tag to favourite support
|
||||
const FavoriteOperation = ({ tag: _ }: { tag: ListItem }) => {
|
||||
// const t = useI18n();
|
||||
// const favAdapter = useService(FavoriteItemsAdapter);
|
||||
// const isFavorite = useLiveData(
|
||||
// favAdapter.isFavorite$(tag.id, 'tag')
|
||||
// );
|
||||
const FavoriteOperation = ({ tag }: { tag: ListItem }) => {
|
||||
const t = useI18n();
|
||||
const favoriteService = useService(FavoriteService);
|
||||
const isFavorite = useLiveData(
|
||||
favoriteService.favoriteList.isFavorite$('tag', tag.id)
|
||||
);
|
||||
|
||||
// const onToggleFavoriteCollection = useCallback(() => {
|
||||
// favAdapter.toggle(tag.id, 'tag');
|
||||
// toast(
|
||||
// isFavorite
|
||||
// ? t['com.affine.toastMessage.removedFavorites']()
|
||||
// : t['com.affine.toastMessage.addedFavorites']()
|
||||
// );
|
||||
// }, [tag.id, favAdapter, isFavorite, t]);
|
||||
const onToggleFavoriteCollection = useCallback(() => {
|
||||
favoriteService.favoriteList.toggle('tag', tag.id);
|
||||
toast(
|
||||
isFavorite
|
||||
? t['com.affine.toastMessage.removedFavorites']()
|
||||
: t['com.affine.toastMessage.addedFavorites']()
|
||||
);
|
||||
}, [favoriteService.favoriteList, tag.id, isFavorite, t]);
|
||||
|
||||
// return (
|
||||
// <FavoriteTag
|
||||
// style={{ marginRight: 8 }}
|
||||
// onClick={onToggleFavoriteCollection}
|
||||
// active={isFavorite}
|
||||
// />
|
||||
// );
|
||||
|
||||
return null;
|
||||
return (
|
||||
<FavoriteTag
|
||||
style={{ marginRight: 8 }}
|
||||
onClick={onToggleFavoriteCollection}
|
||||
active={isFavorite}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export const SelectTag = ({
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
ExplorerCollections,
|
||||
ExplorerFavorites,
|
||||
ExplorerMigrationFavorites,
|
||||
ExplorerOldFavorites,
|
||||
ExplorerOrganize,
|
||||
} from '@affine/core/modules/explorer';
|
||||
import { ExplorerTags } from '@affine/core/modules/explorer/views/sections/tags';
|
||||
@@ -169,10 +168,9 @@ export const RootAppSidebar = (): ReactElement => {
|
||||
</MenuItem>
|
||||
</SidebarContainer>
|
||||
<SidebarScrollableContainer>
|
||||
{runtimeConfig.enableNewFavorite && <ExplorerFavorites />}
|
||||
<ExplorerFavorites />
|
||||
{runtimeConfig.enableOrganize && <ExplorerOrganize />}
|
||||
{runtimeConfig.enableNewFavorite && <ExplorerMigrationFavorites />}
|
||||
{runtimeConfig.enableOldFavorite && <ExplorerOldFavorites />}
|
||||
<ExplorerMigrationFavorites />
|
||||
<ExplorerCollections />
|
||||
<ExplorerTags />
|
||||
<CategoryDivider label={t['com.affine.rootAppSidebar.others']()} />
|
||||
|
||||
Reference in New Issue
Block a user