fix(desktop): update date when date prop updated
- Simplified date string setting logic in RelativeDay component. - Added spacing in EntryHeadDateItem for better layout. - Consolidated className definition in DateItem component for consistency. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -62,9 +62,8 @@ export const RelativeDay = ({ date }: { date: Date }) => {
|
||||
timerRef.current = setTimeout(() => {
|
||||
setDateString(formatDateString(date))
|
||||
}, updateInterval)
|
||||
} else {
|
||||
setDateString(formatDateString(date))
|
||||
}
|
||||
setDateString(formatDateString(date))
|
||||
|
||||
return () => {
|
||||
timerRef.current = clearTimeout(timerRef.current)
|
||||
@@ -72,6 +71,7 @@ export const RelativeDay = ({ date }: { date: Date }) => {
|
||||
}, [date, formatDateString, language])
|
||||
|
||||
const formated = dayjs(date).format(formatTemplateStringShort)
|
||||
|
||||
if (formated === dateString) {
|
||||
return <>{dateString}</>
|
||||
}
|
||||
|
||||
@@ -40,13 +40,12 @@ const useParseDate = (date: string) =>
|
||||
}
|
||||
}, [date])
|
||||
|
||||
const dateItemclassName = tw`relative flex items-center text-sm lg:text-base gap-1 bg-background px-4 font-bold text-zinc-800 dark:text-neutral-400 h-7`
|
||||
export const DateItem = memo(({ date, view, isSticky }: DateItemProps) => {
|
||||
const className = tw`relative flex items-center text-sm lg:text-base gap-1 bg-background px-4 font-bold text-zinc-800 dark:text-neutral-400 h-7`
|
||||
|
||||
if (view === FeedViewType.SocialMedia) {
|
||||
return <SocialMediaDateItem date={date} className={className} isSticky={isSticky} />
|
||||
return <SocialMediaDateItem date={date} className={dateItemclassName} isSticky={isSticky} />
|
||||
}
|
||||
return <UniversalDateItem date={date} className={className} isSticky={isSticky} />
|
||||
return <UniversalDateItem date={date} className={dateItemclassName} isSticky={isSticky} />
|
||||
})
|
||||
const UniversalDateItem = ({ date, className, isSticky }: Omit<DateItemProps, "view">) => {
|
||||
const { startOfDay, endOfDay, dateObj } = useParseDate(date)
|
||||
|
||||
@@ -302,6 +302,7 @@ const EntryHeadDateItem: FC<{
|
||||
const date = new Date(
|
||||
isList ? entry.entries.insertedAt : entry.entries.publishedAt,
|
||||
).toDateString()
|
||||
|
||||
return <DateItem isSticky={isSticky} date={date} view={view} />
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user