diff --git a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/hooks/dateMentionUtils.ts b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/hooks/dateMentionUtils.ts index 2e3271fd1..5cca6820c 100644 --- a/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/hooks/dateMentionUtils.ts +++ b/apps/desktop/layer/renderer/src/modules/ai-chat/editor/plugins/mention/hooks/dateMentionUtils.ts @@ -13,34 +13,24 @@ export interface DateRange { end: Dayjs } -export const formatRangeValue = (range: DateRange, id?: string): string => { +const formatRangeValue = (range: DateRange, text?: string): string => { const startIso = range.start.format(MENTION_DATE_VALUE_FORMAT) const endIso = range.end.format(MENTION_DATE_VALUE_FORMAT) - return `` + return `` } -const DEFAULT_DATE_FORMAT: Intl.DateTimeFormatOptions = { - year: "numeric", - month: "short", - day: "numeric", -} - -export const formatLocalizedDate = ( - date: Dayjs, - locale: string, - options: Intl.DateTimeFormatOptions = DEFAULT_DATE_FORMAT, -): string => { - return new Intl.DateTimeFormat(locale, options).format(date.toDate()) +const formatLocalizedDate = (date: Dayjs, locale: string, template = "LLL"): string => { + return date.locale(locale).format(template) } export const formatLocalizedRange = ( range: DateRange, locale: string, - options: Intl.DateTimeFormatOptions = DEFAULT_DATE_FORMAT, + template?: string, ): string => { - const startFormatted = formatLocalizedDate(range.start, locale, options) - const endFormatted = formatLocalizedDate(range.end, locale, options) + const startFormatted = formatLocalizedDate(range.start, locale, template) + const endFormatted = formatLocalizedDate(range.end, locale, template) if (startFormatted === endFormatted) { return startFormatted @@ -103,7 +93,7 @@ export const createDateMentionData = ({ const value = formatRangeValue(range, id || displayName) const text = value // Use the same value for text - const resolvedName = displayName ?? resolveMentionLabel(label, translate) ?? value + const resolvedName = displayName ?? (resolveMentionLabel(label, translate) || "") return { id: id ?? `date:${value}`, @@ -161,5 +151,7 @@ export const getDateMentionDisplayName = ( return translate(matched.labelKey) } - return asRange ? formatLocalizedRange(range, locale) : mention.name + return asRange + ? formatLocalizedRange(range, locale) + : mention.name || formatLocalizedRange(range, locale, "LL") } diff --git a/apps/desktop/layer/renderer/src/modules/new-user-guide/pre-finish.tsx b/apps/desktop/layer/renderer/src/modules/new-user-guide/pre-finish.tsx index a9835d1b7..f256c49ce 100644 --- a/apps/desktop/layer/renderer/src/modules/new-user-guide/pre-finish.tsx +++ b/apps/desktop/layer/renderer/src/modules/new-user-guide/pre-finish.tsx @@ -29,7 +29,7 @@ export function PreFinish() { try { await subscriptionSyncService.subscribe({ url, - view: FeedViewType.All, + view: feed.analytics.view ?? FeedViewType.Articles, category: null, isPrivate: false, hideFromTimeline: null, diff --git a/apps/desktop/layer/renderer/src/modules/new-user-guide/store.ts b/apps/desktop/layer/renderer/src/modules/new-user-guide/store.ts index 93b4ee548..5eb3dc63d 100644 --- a/apps/desktop/layer/renderer/src/modules/new-user-guide/store.ts +++ b/apps/desktop/layer/renderer/src/modules/new-user-guide/store.ts @@ -1,4 +1,5 @@ import type { MediaModel } from "@follow/database/schemas/types" +import type { FeedViewType } from "@follow-app/client-sdk" import { atom } from "jotai" import { splitAtom } from "jotai/utils" @@ -22,6 +23,10 @@ export type FeedSelection = { title: string | null url: string | null }[] + + analytics: { + view: FeedViewType | null + } } export const feedSelectionsAtom = atom([])