mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
feat(core): add flag for two-step journal conformation (#13246)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced a feature flag to control a two-step journal confirmation process. * Users may now experience either an immediate journal opening or a confirmation step before journal creation, depending on the feature flag status. * **Chores** * Added a new feature flag for two-step journal confirmation, configurable in canary builds. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { WeekDatePickerHandle } from '@affine/component';
|
||||
import { WeekDatePicker } from '@affine/component';
|
||||
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
|
||||
import {
|
||||
JOURNAL_DATE_FORMAT,
|
||||
JournalService,
|
||||
@@ -25,6 +26,11 @@ export const JournalWeekDatePicker = ({ page }: JournalWeekDatePickerProps) => {
|
||||
);
|
||||
const workbench = useService(WorkbenchService).workbench;
|
||||
|
||||
const featureFlagService = useService(FeatureFlagService);
|
||||
const isTwoStepJournalConfirmationEnabled = useLiveData(
|
||||
featureFlagService.flags.enable_two_step_journal_confirmation.$
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!journalDate) return;
|
||||
setDate(journalDate.format(JOURNAL_DATE_FORMAT));
|
||||
@@ -33,14 +39,19 @@ export const JournalWeekDatePicker = ({ page }: JournalWeekDatePickerProps) => {
|
||||
|
||||
const openJournal = useCallback(
|
||||
(date: string) => {
|
||||
const docs = journalService.journalsByDate$(date).value;
|
||||
if (docs.length > 0) {
|
||||
workbench.openDoc(docs[0].id, { at: 'active' });
|
||||
if (isTwoStepJournalConfirmationEnabled) {
|
||||
const docs = journalService.journalsByDate$(date).value;
|
||||
if (docs.length > 0) {
|
||||
workbench.openDoc(docs[0].id, { at: 'active' });
|
||||
} else {
|
||||
workbench.open(`/journals?date=${date}`, { at: 'active' });
|
||||
}
|
||||
} else {
|
||||
workbench.open(`/journals?date=${date}`, { at: 'active' });
|
||||
const doc = journalService.ensureJournalByDate(date);
|
||||
workbench.openDoc(doc.id, { at: 'active' });
|
||||
}
|
||||
},
|
||||
[journalService, workbench]
|
||||
[isTwoStepJournalConfirmationEnabled, journalService, workbench]
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user