A much more detailed notification

This commit is contained in:
2026-02-27 07:05:08 +08:00
parent 9cc99e612a
commit dab43a7f30
9 changed files with 178 additions and 41 deletions
-1
View File
@@ -4,7 +4,6 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'notifications_provider.dart';
import '../utils/device_id.dart';
import 'supabase_provider.dart';
+6 -6
View File
@@ -121,14 +121,14 @@ class NotificationsController {
actorId: actorId,
fields: {
'message_id': messageId,
if (ticketId != null) 'ticket_id': ticketId,
if (taskId != null) 'task_id': taskId,
...?(ticketId != null ? {'ticket_id': ticketId} : null),
...?(taskId != null ? {'task_id': taskId} : null),
},
pushTitle: 'New mention',
pushBody: 'You were mentioned in a message',
pushData: {
if (ticketId != null) 'ticket_id': ticketId,
if (taskId != null) 'task_id': taskId,
...?(ticketId != null ? {'ticket_id': ticketId} : null),
...?(taskId != null ? {'task_id': taskId} : null),
},
);
}
@@ -240,8 +240,8 @@ class NotificationsController {
return;
}
final bodyPayload = <String, dynamic>{
if (tokens != null) 'tokens': tokens,
if (userIds != null) 'user_ids': userIds,
'tokens': tokens ?? [],
'user_ids': userIds ?? [],
'title': title,
'body': body,
'data': data ?? {},
+5 -5
View File
@@ -197,7 +197,7 @@ final tasksProvider = StreamProvider<List<Task>>((ref) {
// 2. in_progress preserve recent order (created_at asc)
// 3. completed order by numeric task_number when available (asc)
// 4. other statuses fallback to queue_order then created_at
final statusRank = (String s) {
int statusRank(String s) {
switch (s) {
case 'queued':
return 0;
@@ -208,9 +208,9 @@ final tasksProvider = StreamProvider<List<Task>>((ref) {
default:
return 3;
}
};
}
int? _parseTaskNumber(Task t) {
int? parseTaskNumber(Task t) {
final tn = t.taskNumber;
if (tn == null) return null;
final m = RegExp(r'\d+').firstMatch(tn);
@@ -243,8 +243,8 @@ final tasksProvider = StreamProvider<List<Task>>((ref) {
if (ra == 2) {
// completed: prefer numeric task_number DESC when present
final an = _parseTaskNumber(a);
final bn = _parseTaskNumber(b);
final an = parseTaskNumber(a);
final bn = parseTaskNumber(b);
if (an != null && bn != null) return bn.compareTo(an);
if (an != null) return -1;
if (bn != null) return 1;