Offline Support
This commit is contained in:
@@ -14,6 +14,7 @@ import '../../widgets/app_page_header.dart';
|
||||
import '../../widgets/m3_card.dart';
|
||||
import '../../widgets/profile_avatar.dart';
|
||||
import '../../widgets/responsive_body.dart';
|
||||
import '../../widgets/sync_pending_badge.dart';
|
||||
import 'announcement_comments_section.dart';
|
||||
import 'create_announcement_dialog.dart';
|
||||
|
||||
@@ -317,6 +318,14 @@ class _AnnouncementCardState extends ConsumerState<_AnnouncementCard> {
|
||||
ref.watch(announcementCommentsProvider(widget.announcement.id));
|
||||
final commentCount = commentsAsync.valueOrNull?.length ?? 0;
|
||||
|
||||
// Pending-sync state
|
||||
final pendingNew = ref
|
||||
.watch(offlinePendingAnnouncementsProvider)
|
||||
.any((a) => a.id == widget.announcement.id);
|
||||
final pendingUpdates = ref.watch(offlinePendingAnnouncementUpdatesProvider);
|
||||
final isAnnouncementPending =
|
||||
pendingNew || pendingUpdates.containsKey(widget.announcement.id);
|
||||
|
||||
// Rebuild UI when cooldown is active.
|
||||
if (_inCooldown) {
|
||||
Future.delayed(const Duration(milliseconds: 500), () {
|
||||
@@ -428,9 +437,21 @@ class _AnnouncementCardState extends ConsumerState<_AnnouncementCard> {
|
||||
// Title + Body
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Text(
|
||||
widget.announcement.title,
|
||||
style: tt.titleMedium?.copyWith(fontWeight: FontWeight.w600),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
widget.announcement.title,
|
||||
style: tt.titleMedium
|
||||
?.copyWith(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
if (isAnnouncementPending) ...[
|
||||
const SizedBox(width: 8),
|
||||
SyncPendingBadge(isPending: true, compact: true),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
|
||||
Reference in New Issue
Block a user