mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
feat(core): page info adapter for journal (#5561)
Page info adapter + schema. Adapted for journal features. 
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { usePageMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
|
||||
import { useBlockSuiteWorkspacePage } from '@affine/core/hooks/use-block-suite-workspace-page';
|
||||
import { timestampToLocalDate } from '@affine/core/utils';
|
||||
import { DebugLogger } from '@affine/debug';
|
||||
import {
|
||||
fetchWithTraceReport,
|
||||
@@ -176,11 +177,7 @@ export const useSnapshotPage = (
|
||||
export const historyListGroupByDay = (histories: DocHistory[]) => {
|
||||
const map = new Map<string, DocHistory[]>();
|
||||
for (const history of histories) {
|
||||
const day = new Date(history.timestamp).toLocaleDateString(undefined, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
});
|
||||
const day = timestampToLocalDate(history.timestamp);
|
||||
const list = map.get(day) ?? [];
|
||||
list.push(history);
|
||||
map.set(day, list);
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useIsWorkspaceOwner } from '@affine/core/hooks/affine/use-is-workspace-
|
||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||
import { useUserSubscription } from '@affine/core/hooks/use-subscription';
|
||||
import { waitForCurrentWorkspaceAtom } from '@affine/core/modules/workspace';
|
||||
import { timestampToLocalTime } from '@affine/core/utils';
|
||||
import { SubscriptionPlan } from '@affine/graphql';
|
||||
import { Trans } from '@affine/i18n';
|
||||
import { useAFFiNEI18N } from '@affine/i18n/hooks';
|
||||
@@ -88,14 +89,6 @@ const ModalContainer = ({
|
||||
);
|
||||
};
|
||||
|
||||
const localTimeFormatter = new Intl.DateTimeFormat('en', {
|
||||
timeStyle: 'short',
|
||||
});
|
||||
|
||||
const timestampToLocalTime = (ts: string) => {
|
||||
return localTimeFormatter.format(new Date(ts));
|
||||
};
|
||||
|
||||
interface HistoryEditorPreviewProps {
|
||||
ts?: string;
|
||||
snapshotPage?: Page;
|
||||
|
||||
@@ -19,7 +19,7 @@ export const JournalWeekDatePicker = ({
|
||||
page,
|
||||
}: JournalWeekDatePickerProps) => {
|
||||
const handleRef = useRef<WeekDatePickerHandle>(null);
|
||||
const { journalDate } = useJournalInfoHelper(page.meta);
|
||||
const { journalDate } = useJournalInfoHelper(workspace, page.id);
|
||||
const { openJournal } = useJournalHelper(workspace);
|
||||
const [date, setDate] = useState(
|
||||
(journalDate ?? dayjs()).format('YYYY-MM-DD')
|
||||
|
||||
@@ -19,9 +19,11 @@ export const AppSidebarJournalButton = ({
|
||||
}: AppSidebarJournalButtonProps) => {
|
||||
const t = useAFFiNEI18N();
|
||||
const currentPageId = useAtomValue(currentPageIdAtom);
|
||||
const currentPage = currentPageId ? workspace.getPage(currentPageId) : null;
|
||||
const { openToday } = useJournalHelper(workspace);
|
||||
const { journalDate, isJournal } = useJournalInfoHelper(currentPage?.meta);
|
||||
const { journalDate, isJournal } = useJournalInfoHelper(
|
||||
workspace,
|
||||
currentPageId
|
||||
);
|
||||
const params = useParams();
|
||||
const isJournalActive = isJournal && !!params.pageId;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user