Fix stale conversation sync labels on mobile
This commit is contained in:
@@ -180,6 +180,20 @@ export function formatTimestampLabel(value?: string, fallback = "刚刚") {
|
||||
return shanghaiDayFormatter.format(date);
|
||||
}
|
||||
|
||||
const STALE_CONTEXT_SYNC_LABEL = "待同步";
|
||||
const STALE_CONTEXT_REPLY_THRESHOLD_MS = 7 * 24 * 60 * 60_000;
|
||||
|
||||
function formatConversationLatestReplyLabel(value: string, hasVisibleContext: boolean) {
|
||||
if (hasVisibleContext && value.includes("T")) {
|
||||
const date = new Date(value);
|
||||
const diff = Date.now() - date.getTime();
|
||||
if (!Number.isNaN(date.getTime()) && diff >= STALE_CONTEXT_REPLY_THRESHOLD_MS) {
|
||||
return STALE_CONTEXT_SYNC_LABEL;
|
||||
}
|
||||
}
|
||||
return formatTimestampLabel(value);
|
||||
}
|
||||
|
||||
function compareSnapshots(a: ThreadContextSnapshot, b: ThreadContextSnapshot) {
|
||||
if (a.mustFinishBeforeCompaction !== b.mustFinishBeforeCompaction) {
|
||||
return a.mustFinishBeforeCompaction ? -1 : 1;
|
||||
@@ -386,7 +400,10 @@ function buildConversationItem(state: BossState, project: Project): Conversation
|
||||
topPinnedLabel,
|
||||
manualPinned: Boolean(project.pinned && !project.systemPinned),
|
||||
latestReplyAt: latestConversationActivityAt,
|
||||
latestReplyLabel: formatTimestampLabel(latestConversationActivityAt),
|
||||
latestReplyLabel: formatConversationLatestReplyLabel(
|
||||
latestConversationActivityAt,
|
||||
Boolean(topThread),
|
||||
),
|
||||
unreadCount: project.unreadCount,
|
||||
riskLevel: project.riskLevel,
|
||||
activeDeviceCount: devices.length,
|
||||
|
||||
Reference in New Issue
Block a user