feat(core): set journal's really created time (#5968)

closes #5958;

This makes the creation date of the journal correspond to the date, and the creation time is the real creation time.
This commit is contained in:
Cats Juice 2024-03-05 03:37:23 +00:00
parent 3fcbfe4d30
commit 358e1e99c5
No known key found for this signature in database
GPG Key ID: 1C1E76924FAFDDE4

View File

@ -31,11 +31,17 @@ export const useJournalHelper = (workspace: BlockSuiteWorkspace) => {
*/
const _createJournal = useCallback(
(maybeDate: MaybeDate) => {
const title = dayjs(maybeDate).format(JOURNAL_DATE_FORMAT);
const day = dayjs(maybeDate);
const title = day.format(JOURNAL_DATE_FORMAT);
const page = bsWorkspaceHelper.createDoc();
// set created date to match the journal date
page.workspace.setDocMeta(page.id, {
createDate: dayjs(maybeDate).toDate().getTime(),
createDate: dayjs()
.set('year', day.year())
.set('month', day.month())
.set('date', day.date())
.toDate()
.getTime(),
});
initEmptyPage(page, title);
adapter.setJournalPageDateString(page.id, title);