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:
Cats Juice
2025-07-17 15:03:32 +08:00
committed by GitHub
parent 21360591a9
commit ea21de8311
4 changed files with 78 additions and 12 deletions
@@ -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 (