mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 22:38:56 +08:00
style: enable rxjs/finnish (#6276)
chore(infra): use finnish notation for observables do rename
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ export const DumpInfo = (_props: DumpInfoProps) => {
|
||||
const location = useLocation();
|
||||
const workspaceList = useService(WorkspaceListService);
|
||||
const currentWorkspace = useLiveData(
|
||||
useService(CurrentWorkspaceService).currentWorkspace
|
||||
useService(CurrentWorkspaceService).currentWorkspace$
|
||||
);
|
||||
const path = location.pathname;
|
||||
const query = useParams();
|
||||
|
||||
@@ -9,7 +9,7 @@ import { CurrentWorkspaceService } from '../../../modules/workspace/current-work
|
||||
const SyncAwarenessInnerLoggedIn = () => {
|
||||
const { user } = useSession();
|
||||
const currentWorkspace = useLiveData(
|
||||
useService(CurrentWorkspaceService).currentWorkspace
|
||||
useService(CurrentWorkspaceService).currentWorkspace$
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -479,7 +479,7 @@ const PageHistoryManager = ({
|
||||
);
|
||||
|
||||
const page = useService(Doc);
|
||||
const [mode, setMode] = useState<PageMode>(page.mode.value);
|
||||
const [mode, setMode] = useState<PageMode>(page.mode$.value);
|
||||
|
||||
const title = useDocCollectionPageTitle(docCollection, pageId);
|
||||
|
||||
|
||||
+15
-19
@@ -42,8 +42,8 @@ const InlineTagsList = ({
|
||||
children,
|
||||
}: PropsWithChildren<InlineTagsListProps>) => {
|
||||
const tagService = useService(TagService);
|
||||
const tags = useLiveData(tagService.tags);
|
||||
const tagIds = useLiveData(tagService.tagIdsByPageId(pageId));
|
||||
const tags = useLiveData(tagService.tags$);
|
||||
const tagIds = useLiveData(tagService.tagIdsByPageId$(pageId));
|
||||
|
||||
return (
|
||||
<div className={styles.inlineTagsContainer} data-testid="inline-tags-list">
|
||||
@@ -83,9 +83,9 @@ export const EditTagMenu = ({
|
||||
const t = useAFFiNEI18N();
|
||||
const legacyProperties = useService(WorkspaceLegacyProperties);
|
||||
const tagService = useService(TagService);
|
||||
const tag = useLiveData(tagService.tagByTagId(tagId));
|
||||
const tagColor = useLiveData(tag?.color);
|
||||
const tagValue = useLiveData(tag?.value);
|
||||
const tag = useLiveData(tagService.tagByTagId$(tagId));
|
||||
const tagColor = useLiveData(tag?.color$);
|
||||
const tagValue = useLiveData(tag?.value$);
|
||||
const navigate = useNavigateHelper();
|
||||
|
||||
const menuProps = useMemo(() => {
|
||||
@@ -135,11 +135,11 @@ export const EditTagMenu = ({
|
||||
options.push('-');
|
||||
|
||||
options.push(
|
||||
tagColors.map(([name, color]) => {
|
||||
tagColors.map(([name, color], i) => {
|
||||
return {
|
||||
text: name,
|
||||
icon: (
|
||||
<div className={styles.tagColorIconWrapper}>
|
||||
<div key={i} className={styles.tagColorIconWrapper}>
|
||||
<div
|
||||
className={styles.tagColorIcon}
|
||||
style={{
|
||||
@@ -181,8 +181,8 @@ export const EditTagMenu = ({
|
||||
export const TagsEditor = ({ pageId, readonly }: TagsEditorProps) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const tagService = useService(TagService);
|
||||
const tags = useLiveData(tagService.tags);
|
||||
const tagIds = useLiveData(tagService.tagIdsByPageId(pageId));
|
||||
const tags = useLiveData(tagService.tags$);
|
||||
const tagIds = useLiveData(tagService.tagIdsByPageId$(pageId));
|
||||
const [inputValue, setInputValue] = useState('');
|
||||
const [open, setOpen] = useState(false);
|
||||
const [selectedTagIds, setSelectedTagIds] = useState<string[]>([]);
|
||||
@@ -203,15 +203,11 @@ export const TagsEditor = ({ pageId, readonly }: TagsEditorProps) => {
|
||||
[setOpen, setSelectedTagIds]
|
||||
);
|
||||
|
||||
const exactMatch = useLiveData(tagService.tagByTagValue(inputValue));
|
||||
const exactMatch = useLiveData(tagService.tagByTagValue$(inputValue));
|
||||
|
||||
const filteredLiveData = useMemo(() => {
|
||||
if (inputValue) {
|
||||
return tagService.filterTagsByName(inputValue);
|
||||
}
|
||||
return tagService.tags;
|
||||
}, [inputValue, tagService]);
|
||||
const filteredTags = useLiveData(filteredLiveData);
|
||||
const filteredTags = useLiveData(
|
||||
inputValue ? tagService.filterTagsByName$(inputValue) : tagService.tags$
|
||||
);
|
||||
|
||||
const onInputChange = useCallback(
|
||||
(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
@@ -295,7 +291,7 @@ export const TagsEditor = ({ pageId, readonly }: TagsEditorProps) => {
|
||||
className={styles.tagSelectorItem}
|
||||
data-testid="tag-selector-item"
|
||||
data-tag-id={tag.id}
|
||||
data-tag-value={tag.value}
|
||||
data-tag-value={tag.value$}
|
||||
onClick={() => {
|
||||
onAddTag(tag.id);
|
||||
}}
|
||||
@@ -351,7 +347,7 @@ export const TagsInlineEditor = ({
|
||||
className,
|
||||
}: TagsInlineEditorProps) => {
|
||||
const tagService = useService(TagService);
|
||||
const tagIds = useLiveData(tagService.tagIdsByPageId(pageId));
|
||||
const tagIds = useLiveData(tagService.tagIdsByPageId$(pageId));
|
||||
const empty = !tagIds || tagIds.length === 0;
|
||||
return (
|
||||
<Menu
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ export const WorkspaceList = ({
|
||||
activeSubTab: WorkspaceSubTab;
|
||||
}) => {
|
||||
const workspaces = useLiveData(
|
||||
useService(WorkspaceManager).list.workspaceList
|
||||
useService(WorkspaceManager).list.workspaceList$
|
||||
);
|
||||
return (
|
||||
<>
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ export const DeleteLeaveWorkspace = ({
|
||||
const setSettingModal = useSetAtom(openSettingModalAtom);
|
||||
|
||||
const workspaceManager = useService(WorkspaceManager);
|
||||
const workspaceList = useLiveData(workspaceManager.list.workspaceList);
|
||||
const workspaceList = useLiveData(workspaceManager.list.workspaceList$);
|
||||
const currentWorkspace = useService(Workspace);
|
||||
const pushNotification = useSetAtom(pushNotificationAtom);
|
||||
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ export const ProfilePanel = ({ isOwner, workspace }: ProfilePanelProps) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const pushNotification = useSetAtom(pushNotificationAtom);
|
||||
|
||||
const workspaceIsReady = useLiveData(workspace?.engine.rootDocState)?.ready;
|
||||
const workspaceIsReady = useLiveData(workspace?.engine.rootDocState$)?.ready;
|
||||
|
||||
const [avatarBlob, setAvatarBlob] = useState<string | null>(null);
|
||||
const [name, setName] = useState('');
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ export const ShareExport = ({
|
||||
urlType: 'workspace',
|
||||
});
|
||||
const exportHandler = useExportPage(currentPage);
|
||||
const currentMode = useLiveData(page.mode);
|
||||
const currentMode = useLiveData(page.mode$);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ export const AffineSharePage = (props: ShareMenuProps) => {
|
||||
disableShare,
|
||||
} = useIsSharedPage(workspaceId, currentPage.id);
|
||||
|
||||
const currentPageMode = useLiveData(page.mode);
|
||||
const currentPageMode = useLiveData(page.mode$);
|
||||
|
||||
const defaultMode = useMemo(() => {
|
||||
if (isSharedPage) {
|
||||
|
||||
@@ -55,7 +55,7 @@ export const PageHeaderMenuButton = ({
|
||||
meta => meta.id === pageId
|
||||
);
|
||||
const page = useService(Doc);
|
||||
const currentMode = useLiveData(page.mode);
|
||||
const currentMode = useLiveData(page.mode$);
|
||||
|
||||
const { favorite, toggleFavorite } = useFavorite(pageId);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ export const EditorModeSwitch = ({
|
||||
const trash = pageMeta?.trash ?? false;
|
||||
const page = useService(Doc);
|
||||
|
||||
const currentMode = useLiveData(page.mode);
|
||||
const currentMode = useLiveData(page.mode$);
|
||||
|
||||
useEffect(() => {
|
||||
if (trash || isPublic) {
|
||||
|
||||
@@ -19,7 +19,7 @@ export const usePageHelper = (docCollection: DocCollection) => {
|
||||
|
||||
const isPreferredEdgeless = useCallback(
|
||||
(pageId: string) =>
|
||||
pageRecordList.record(pageId).value?.mode.value === 'edgeless',
|
||||
pageRecordList.record$(pageId).value?.mode$.value === 'edgeless',
|
||||
[pageRecordList]
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ export const usePageHelper = (docCollection: DocCollection) => {
|
||||
(mode?: 'page' | 'edgeless') => {
|
||||
const page = createDoc();
|
||||
initEmptyPage(page);
|
||||
pageRecordList.record(page.id).value?.setMode(mode || 'page');
|
||||
pageRecordList.record$(page.id).value?.setMode(mode || 'page');
|
||||
openPage(docCollection.id, page.id);
|
||||
return page;
|
||||
},
|
||||
|
||||
@@ -49,7 +49,7 @@ const PageDetailEditorMain = memo(function PageDetailEditorMain({
|
||||
isPublic,
|
||||
publishMode,
|
||||
}: PageDetailEditorProps & { page: BlockSuiteDoc }) {
|
||||
const currentMode = useLiveData(useService(Doc).mode);
|
||||
const currentMode = useLiveData(useService(Doc).mode$);
|
||||
const mode = useMemo(() => {
|
||||
const shareMode = publishMode || currentMode;
|
||||
|
||||
|
||||
@@ -94,8 +94,8 @@ export const TagPageListHeader = ({
|
||||
tag: Tag;
|
||||
workspaceId: string;
|
||||
}) => {
|
||||
const tagColor = useLiveData(tag.color);
|
||||
const tagTitle = useLiveData(tag.value);
|
||||
const tagColor = useLiveData(tag.color$);
|
||||
const tagTitle = useLiveData(tag.value$);
|
||||
|
||||
const t = useAFFiNEI18N();
|
||||
const { jumpToTags, jumpToCollection } = useNavigateHelper();
|
||||
@@ -183,13 +183,9 @@ export const SwitchTag = ({ onClick }: SwitchTagProps) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const [inputValue, setInputValue] = useState('');
|
||||
const tagService = useService(TagService);
|
||||
const filteredLiveData = useMemo(() => {
|
||||
if (inputValue) {
|
||||
return tagService.filterTagsByName(inputValue);
|
||||
}
|
||||
return tagService.tags;
|
||||
}, [inputValue, tagService]);
|
||||
const filteredTags = useLiveData(filteredLiveData);
|
||||
const filteredTags = useLiveData(
|
||||
inputValue ? tagService.filterTagsByName$(inputValue) : tagService.tags$
|
||||
);
|
||||
|
||||
const onInputChange = useCallback(
|
||||
(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
@@ -238,8 +234,8 @@ export const SwitchTag = ({ onClick }: SwitchTagProps) => {
|
||||
};
|
||||
|
||||
const TagLink = ({ tag, onClick }: { tag: Tag; onClick: () => void }) => {
|
||||
const tagColor = useLiveData(tag.color);
|
||||
const tagTitle = useLiveData(tag.value);
|
||||
const tagColor = useLiveData(tag.color$);
|
||||
const tagTitle = useLiveData(tag.value$);
|
||||
return (
|
||||
<Link
|
||||
key={tag.id}
|
||||
|
||||
@@ -69,8 +69,7 @@ const PageSelectionCell = ({
|
||||
|
||||
export const PageTagsCell = ({ pageId }: Pick<PageListItemProps, 'pageId'>) => {
|
||||
const tagsService = useService(TagService);
|
||||
const tagsLiveData = tagsService.tagsByPageId(pageId);
|
||||
const tags = useLiveData(tagsLiveData);
|
||||
const tags = useLiveData(tagsService.tagsByPageId$(pageId));
|
||||
|
||||
return (
|
||||
<div data-testid="page-list-item-tags" className={styles.tagsCell}>
|
||||
|
||||
@@ -57,8 +57,8 @@ export const TagItem = ({
|
||||
style,
|
||||
maxWidth,
|
||||
}: TagItemProps) => {
|
||||
const value = useLiveData(tag?.value);
|
||||
const color = useLiveData(tag?.color);
|
||||
const value = useLiveData(tag?.value$);
|
||||
const color = useLiveData(tag?.color$);
|
||||
const handleRemove: MouseEventHandler = useCallback(
|
||||
e => {
|
||||
e.stopPropagation();
|
||||
@@ -112,13 +112,13 @@ const TagItemNormal = ({
|
||||
return maxItems ? tags.slice(0, maxItems) : tags;
|
||||
}, [maxItems, tags]);
|
||||
|
||||
const tagsOrderedLiveData = useMemo(() => {
|
||||
return LiveData.computed(get =>
|
||||
[...nTags].sort((a, b) => get(a.value).length - get(b.value).length)
|
||||
);
|
||||
}, [nTags]);
|
||||
|
||||
const tagsOrdered = useLiveData(tagsOrderedLiveData);
|
||||
const tagsOrdered = useLiveData(
|
||||
useMemo(() => {
|
||||
return LiveData.computed(get =>
|
||||
[...nTags].sort((a, b) => get(a.value$).length - get(b.value$).length)
|
||||
);
|
||||
}, [nTags])
|
||||
);
|
||||
|
||||
return useMemo(
|
||||
() =>
|
||||
|
||||
@@ -275,11 +275,11 @@ function tagIdToTagOption(
|
||||
|
||||
const PageTitle = ({ id }: { id: string }) => {
|
||||
const page = useLiveData(
|
||||
useService(PageRecordList).records.map(record => {
|
||||
useService(PageRecordList).records$.map(record => {
|
||||
return record.find(p => p.id === id);
|
||||
})
|
||||
);
|
||||
const title = useLiveData(page?.title);
|
||||
const title = useLiveData(page?.title$);
|
||||
const t = useAFFiNEI18N();
|
||||
return title || t['Untitled']();
|
||||
};
|
||||
|
||||
@@ -33,8 +33,8 @@ export const CreateOrEditTag = ({
|
||||
tagMeta?: TagMeta;
|
||||
}) => {
|
||||
const tagService = useService(TagService);
|
||||
const tagOptions = useLiveData(tagService.tagMetas);
|
||||
const tag = useLiveData(tagService.tagByTagId(tagMeta?.id));
|
||||
const tagOptions = useLiveData(tagService.tagMetas$);
|
||||
const tag = useLiveData(tagService.tagByTagId$(tagMeta?.id));
|
||||
const t = useAFFiNEI18N();
|
||||
const [menuOpen, setMenuOpen] = useState(false);
|
||||
|
||||
|
||||
@@ -107,8 +107,8 @@ export const pageToCommand = (
|
||||
subTitle?: string,
|
||||
blockId?: string
|
||||
): CMDKCommand => {
|
||||
const pageMode = workspace.services.get(PageRecordList).record(page.id).value
|
||||
?.mode.value;
|
||||
const pageMode = workspace.services.get(PageRecordList).record$(page.id).value
|
||||
?.mode$.value;
|
||||
|
||||
const title = getPageTitle(page.id) || t['Untitled']();
|
||||
const commandLabel = {
|
||||
@@ -320,7 +320,7 @@ export const collectionToCommand = (
|
||||
export const useCollectionsCommands = () => {
|
||||
// todo: considering collections for searching pages
|
||||
const collectionService = useService(CollectionService);
|
||||
const collections = useLiveData(collectionService.collections);
|
||||
const collections = useLiveData(collectionService.collections$);
|
||||
const query = useAtomValue(cmdkQueryAtom);
|
||||
const navigationHelper = useNavigateHelper();
|
||||
const t = useAFFiNEI18N();
|
||||
@@ -356,7 +356,7 @@ export const useCMDKCommandGroups = () => {
|
||||
const collectionCommands = useCollectionsCommands();
|
||||
|
||||
const currentPage = useServiceOptional(Doc);
|
||||
const currentPageMode = useLiveData(currentPage?.mode);
|
||||
const currentPageMode = useLiveData(currentPage?.mode$);
|
||||
const affineCommands = useMemo(() => {
|
||||
return getAllCommand({
|
||||
pageMode: currentPageMode,
|
||||
|
||||
@@ -30,7 +30,7 @@ const showList = environment.isDesktop ? DESKTOP_SHOW_LIST : DEFAULT_SHOW_LIST;
|
||||
export const HelpIsland = () => {
|
||||
const page = useServiceOptional(Doc);
|
||||
const pageId = page?.id;
|
||||
const mode = useLiveData(page?.mode);
|
||||
const mode = useLiveData(page?.mode$);
|
||||
const setOpenSettingModalAtom = useSetAtom(openSettingModalAtom);
|
||||
const [spread, setShowSpread] = useState(false);
|
||||
const t = useAFFiNEI18N();
|
||||
|
||||
@@ -19,7 +19,7 @@ import * as styles from './styles.css';
|
||||
|
||||
export const TrashPageFooter = ({ pageId }: { pageId: string }) => {
|
||||
const workspace = useLiveData(
|
||||
useService(CurrentWorkspaceService).currentWorkspace
|
||||
useService(CurrentWorkspaceService).currentWorkspace$
|
||||
);
|
||||
assertExists(workspace);
|
||||
const docCollection = workspace.docCollection;
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ const CollectionRenderer = ({
|
||||
};
|
||||
return filterPage(collection, pageData);
|
||||
});
|
||||
const location = useLiveData(useService(Workbench).location);
|
||||
const location = useLiveData(useService(Workbench).location$);
|
||||
const currentPath = location.pathname;
|
||||
const path = `/collection/${collection.id}`;
|
||||
|
||||
@@ -174,7 +174,7 @@ export const CollectionsList = ({
|
||||
onCreate,
|
||||
}: CollectionsListProps) => {
|
||||
const metas = useBlockSuiteDocMeta(workspace);
|
||||
const collections = useLiveData(useService(CollectionService).collections);
|
||||
const collections = useLiveData(useService(CollectionService).collections$);
|
||||
const t = useAFFiNEI18N();
|
||||
if (collections.length === 0) {
|
||||
return (
|
||||
|
||||
+2
-2
@@ -36,8 +36,8 @@ export const Page = ({
|
||||
|
||||
const pageId = page.id;
|
||||
const active = params.pageId === pageId;
|
||||
const pageRecord = useLiveData(useService(PageRecordList).record(pageId));
|
||||
const pageMode = useLiveData(pageRecord?.mode);
|
||||
const pageRecord = useLiveData(useService(PageRecordList).record$(pageId));
|
||||
const pageMode = useLiveData(pageRecord?.mode$);
|
||||
const dragItemId = getDragItemId('collectionPage', pageId);
|
||||
|
||||
const icon = useMemo(() => {
|
||||
|
||||
+2
-2
@@ -27,8 +27,8 @@ export const ReferencePage = ({
|
||||
const params = useParams();
|
||||
const active = params.pageId === pageId;
|
||||
|
||||
const pageRecord = useLiveData(useService(PageRecordList).record(pageId));
|
||||
const pageMode = useLiveData(pageRecord?.mode);
|
||||
const pageRecord = useLiveData(useService(PageRecordList).record$(pageId));
|
||||
const pageMode = useLiveData(pageRecord?.mode$);
|
||||
const icon = useMemo(() => {
|
||||
return pageMode === 'edgeless' ? <EdgelessIcon /> : <PageIcon />;
|
||||
}, [pageMode]);
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@ export const FavouritePage = ({
|
||||
const params = useParams();
|
||||
const active = params.pageId === pageId;
|
||||
const dragItemId = getDragItemId('favouritePage', pageId);
|
||||
const pageRecord = useLiveData(useService(PageRecordList).record(pageId));
|
||||
const pageMode = useLiveData(pageRecord?.mode);
|
||||
const pageRecord = useLiveData(useService(PageRecordList).record$(pageId));
|
||||
const pageMode = useLiveData(pageRecord?.mode$);
|
||||
|
||||
const icon = useMemo(() => {
|
||||
return pageMode === 'edgeless' ? <EdgelessIcon /> : <PageIcon />;
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ const UserWithWorkspaceListInner = ({
|
||||
}, [onEventEnd, setOpenCreateWorkspaceModal]);
|
||||
|
||||
const workspaceManager = useService(WorkspaceManager);
|
||||
const workspaces = useLiveData(workspaceManager.list.workspaceList);
|
||||
const workspaces = useLiveData(workspaceManager.list.workspaceList$);
|
||||
|
||||
// revalidate workspace list when mounted
|
||||
useEffect(() => {
|
||||
|
||||
+2
-2
@@ -105,7 +105,7 @@ export const AFFiNEWorkspaceList = ({
|
||||
onEventEnd?: () => void;
|
||||
}) => {
|
||||
const workspaces = useLiveData(
|
||||
useService(WorkspaceManager).list.workspaceList
|
||||
useService(WorkspaceManager).list.workspaceList$
|
||||
);
|
||||
|
||||
const setOpenCreateWorkspaceModal = useSetAtom(openCreateWorkspaceModalAtom);
|
||||
@@ -113,7 +113,7 @@ export const AFFiNEWorkspaceList = ({
|
||||
const { jumpToSubPath } = useNavigateHelper();
|
||||
|
||||
const currentWorkspace = useLiveData(
|
||||
useService(CurrentWorkspaceService).currentWorkspace
|
||||
useService(CurrentWorkspaceService).currentWorkspace$
|
||||
);
|
||||
|
||||
const setOpenSettingModalAtom = useSetAtom(openSettingModalAtom);
|
||||
|
||||
@@ -99,7 +99,7 @@ export const RootAppSidebar = ({
|
||||
const { appSettings } = useAppSettingHelper();
|
||||
const docCollection = currentWorkspace.docCollection;
|
||||
const t = useAFFiNEI18N();
|
||||
const currentPath = useLiveData(useService(Workbench).location).pathname;
|
||||
const currentPath = useLiveData(useService(Workbench).location$).pathname;
|
||||
|
||||
const onClickNewPage = useAsyncCallback(async () => {
|
||||
const page = createPage();
|
||||
|
||||
Reference in New Issue
Block a user