Keep relative times in the chat and runs lists up to date

A shared RelativeTimeLabel refreshes at the next minute/hour/day boundary,
pauses while the app is hidden and catches up on resume. It keeps the row's
time style (an unread chat's accent). Continues run #218.
This commit is contained in:
2026-11-01 01:50:24 +00:00
parent f422d26e32
commit 82af7b250f
5 changed files with 212 additions and 10 deletions
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import '../../../../core/api_gateway.dart';
import '../../../../ui/layout/app_list_avatar.dart';
import '../../../../ui/layout/app_list_row.dart';
import '../../../../ui/text/relative_time_label.dart';
import '../../domain/chat_sessions.dart';
import 'chat_adaptive.dart';
import 'session_actions.dart';
@@ -48,6 +49,7 @@ class ChatSessionRow extends StatelessWidget {
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final text = chatSessionSubtitle(session);
final updatedAt = _chatSessionInstant(session['updated_at']);
return AppListRow(
key: Key('chat-row-$id'),
cupertino: cupertino,
@@ -78,7 +80,9 @@ class ChatSessionRow extends StatelessWidget {
],
),
),
time: relativeChatSessionTime(session['updated_at']),
timeWidget: updatedAt == null
? null
: RelativeTimeLabel(instant: updatedAt),
// `Closed` leads the line of a closed chat, then the model and folder.
subtitle: Text.rich(
TextSpan(
@@ -111,6 +115,11 @@ class ChatSessionRow extends StatelessWidget {
}
}
DateTime? _chatSessionInstant(Object? updatedAt) {
final millis = chatSessionMillis(updatedAt);
return millis <= 0 ? null : DateTime.fromMillisecondsSinceEpoch(millis);
}
/// As tall as the title's text, so it follows text scaling.
class _Star extends StatelessWidget {
const _Star({required this.cupertino, required this.color});