mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 08:50:50 +08:00
style: enable rxjs/finnish (#6276)
chore(infra): use finnish notation for observables do rename
This commit is contained in:
@@ -27,7 +27,7 @@ export const Component = () => {
|
||||
const [navigating, setNavigating] = useState(false);
|
||||
const [creating, setCreating] = useState(false);
|
||||
|
||||
const list = useLiveData(useService(WorkspaceListService).workspaceList);
|
||||
const list = useLiveData(useService(WorkspaceListService).workspaceList$);
|
||||
|
||||
const { openPage } = useNavigateHelper();
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ export const Component = () => {
|
||||
workspaceManager,
|
||||
]);
|
||||
|
||||
const pageTitle = useLiveData(page?.title);
|
||||
const pageTitle = useLiveData(page?.title$);
|
||||
|
||||
usePageDocumentTitle(pageTitle);
|
||||
const loginStatus = useCurrentLoginStatus();
|
||||
|
||||
@@ -26,7 +26,7 @@ export const AllCollection = () => {
|
||||
const [hideHeaderCreateNew, setHideHeaderCreateNew] = useState(true);
|
||||
|
||||
const collectionService = useService(CollectionService);
|
||||
const collections = useLiveData(collectionService.collections);
|
||||
const collections = useLiveData(collectionService.collections$);
|
||||
const config = useAllPageListConfig();
|
||||
|
||||
const collectionMetas = useMemo(() => {
|
||||
|
||||
@@ -32,11 +32,11 @@ const EmptyTagListHeader = () => {
|
||||
|
||||
export const AllTag = () => {
|
||||
const tagService = useService(TagService);
|
||||
const tags = useLiveData(tagService.tags);
|
||||
const tags = useLiveData(tagService.tags$);
|
||||
const [open, setOpen] = useState(false);
|
||||
const [selectedTagIds, setSelectedTagIds] = useState<string[]>([]);
|
||||
|
||||
const tagMetas: TagMeta[] = useLiveData(tagService.tagMetas);
|
||||
const tagMetas: TagMeta[] = useLiveData(tagService.tagMetas$);
|
||||
|
||||
const handleCloseModal = useCallback(
|
||||
(open: boolean) => {
|
||||
|
||||
@@ -67,7 +67,7 @@ export const CollectionDetail = ({
|
||||
export const Component = function CollectionPage() {
|
||||
const collectionService = useService(CollectionService);
|
||||
|
||||
const collections = useLiveData(collectionService.collections);
|
||||
const collections = useLiveData(collectionService.collections$);
|
||||
const navigate = useNavigateHelper();
|
||||
const params = useParams();
|
||||
const workspace = useService(Workspace);
|
||||
@@ -76,7 +76,7 @@ export const Component = function CollectionPage() {
|
||||
useEffect(() => {
|
||||
if (!collection) {
|
||||
navigate.jumpToSubPath(workspace.id, WorkspaceSubPath.ALL);
|
||||
const collection = collectionService.collectionsTrash.value.find(
|
||||
const collection = collectionService.collectionsTrash$.value.find(
|
||||
v => v.collection.id === params.collectionId
|
||||
);
|
||||
let text = 'Collection does not exist';
|
||||
@@ -94,7 +94,7 @@ export const Component = function CollectionPage() {
|
||||
}
|
||||
}, [
|
||||
collection,
|
||||
collectionService.collectionsTrash.value,
|
||||
collectionService.collectionsTrash$.value,
|
||||
navigate,
|
||||
params.collectionId,
|
||||
pushNotification,
|
||||
|
||||
@@ -108,9 +108,9 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
||||
|
||||
const isInTrash = pageMeta?.trash;
|
||||
|
||||
const mode = useLiveData(page.mode);
|
||||
const mode = useLiveData(page.mode$);
|
||||
useRegisterBlocksuiteEditorCommands();
|
||||
const title = useLiveData(page.title);
|
||||
const title = useLiveData(page.title$);
|
||||
usePageDocumentTitle(title);
|
||||
|
||||
const onLoad = useCallback(
|
||||
@@ -156,13 +156,13 @@ const DetailPageImpl = memo(function DetailPageImpl() {
|
||||
const disposable = new DisposableGroup();
|
||||
|
||||
pageService.getEditorMode = (pageId: string) =>
|
||||
pageRecordList.record(pageId).value?.mode.value ?? 'page';
|
||||
pageRecordList.record$(pageId).value?.mode$.value ?? 'page';
|
||||
pageService.getDocUpdatedAt = (pageId: string) => {
|
||||
const linkedPage = pageRecordList.record(pageId).value;
|
||||
const linkedPage = pageRecordList.record$(pageId).value;
|
||||
if (!linkedPage) return new Date();
|
||||
|
||||
const updatedDate = linkedPage.meta.value.updatedDate;
|
||||
const createDate = linkedPage.meta.value.createDate;
|
||||
const updatedDate = linkedPage.meta$.value.updatedDate;
|
||||
const createDate = linkedPage.meta$.value.createDate;
|
||||
return updatedDate ? new Date(updatedDate) : new Date(createDate);
|
||||
};
|
||||
|
||||
@@ -278,9 +278,9 @@ export const DetailPage = ({ pageId }: { pageId: string }): ReactElement => {
|
||||
const currentWorkspace = useService(Workspace);
|
||||
const pageRecordList = useService(PageRecordList);
|
||||
|
||||
const pageListReady = useLiveData(pageRecordList.isReady);
|
||||
const pageListReady = useLiveData(pageRecordList.isReady$);
|
||||
|
||||
const pageRecords = useLiveData(pageRecordList.records);
|
||||
const pageRecords = useLiveData(pageRecordList.records$);
|
||||
|
||||
const pageRecord = useMemo(
|
||||
() => pageRecords.find(page => page.id === pageId),
|
||||
@@ -310,7 +310,7 @@ export const DetailPage = ({ pageId }: { pageId: string }): ReactElement => {
|
||||
};
|
||||
}, [currentWorkspace, pageId]);
|
||||
|
||||
const jumpOnce = useLiveData(pageRecord?.meta.map(meta => meta.jumpOnce));
|
||||
const jumpOnce = useLiveData(pageRecord?.meta$.map(meta => meta.jumpOnce));
|
||||
|
||||
useEffect(() => {
|
||||
if (jumpOnce) {
|
||||
|
||||
@@ -39,7 +39,7 @@ export const Component = (): ReactElement => {
|
||||
const params = useParams();
|
||||
|
||||
const { workspaceList, loading: listLoading } = useLiveData(
|
||||
useService(WorkspaceListService).status
|
||||
useService(WorkspaceListService).status$
|
||||
);
|
||||
const workspaceManager = useService(WorkspaceManager);
|
||||
|
||||
@@ -71,7 +71,7 @@ export const Component = (): ReactElement => {
|
||||
|
||||
// avoid doing operation, before workspace is loaded
|
||||
const isRootDocReady =
|
||||
useLiveData(workspace?.engine.rootDocState)?.ready ?? false;
|
||||
useLiveData(workspace?.engine.rootDocState$)?.ready ?? false;
|
||||
|
||||
// if listLoading is false, we can show 404 page, otherwise we should show loading page.
|
||||
if (listLoading === false && meta === undefined) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
ViewBodyIsland,
|
||||
ViewHeaderIsland,
|
||||
} from '@affine/core/modules/workbench';
|
||||
import { LiveData, useLiveData, useService } from '@toeverything/infra';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { Workspace } from '@toeverything/infra';
|
||||
import { useMemo } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
@@ -23,21 +23,9 @@ export const TagDetail = ({ tagId }: { tagId?: string }) => {
|
||||
const pageMetas = useBlockSuiteDocMeta(currentWorkspace.docCollection);
|
||||
|
||||
const tagService = useService(TagService);
|
||||
const currentTagLiveData = tagService.tagByTagId(tagId);
|
||||
const currentTag = useLiveData(currentTagLiveData);
|
||||
const currentTag = useLiveData(tagService.tagByTagId$(tagId));
|
||||
|
||||
const pageIdsLiveData = useMemo(
|
||||
() =>
|
||||
LiveData.computed(get => {
|
||||
const liveTag = get(currentTagLiveData);
|
||||
if (liveTag?.pageIds) {
|
||||
return get(liveTag.pageIds);
|
||||
}
|
||||
return [];
|
||||
}),
|
||||
[currentTagLiveData]
|
||||
);
|
||||
const pageIds = useLiveData(pageIdsLiveData);
|
||||
const pageIds = useLiveData(currentTag?.pageIds$);
|
||||
|
||||
const filteredPageMetas = useMemo(() => {
|
||||
const pageIdsSet = new Set(pageIds);
|
||||
|
||||
Reference in New Issue
Block a user