Fix cached reminder recovery and retain pre-reconcile idle diagnostics
This commit is contained in:
@@ -34,6 +34,7 @@ class ReminderRequest {
|
||||
abstract class ReminderGateway {
|
||||
Future<ReminderPermissions> permissions({required bool request});
|
||||
Future<Set<int>> pendingIds();
|
||||
Future<Set<int>> missingSystemIds(Set<int> ids) async => {};
|
||||
Future<Set<int>> ownedIds() => pendingIds();
|
||||
Future<String> sendTestReminder({required bool scheduled}) async =>
|
||||
'当前环境不支持通知测试';
|
||||
@@ -124,6 +125,8 @@ class LocalNotificationService extends NotificationService {
|
||||
);
|
||||
}
|
||||
final pending = await gateway.pendingIds();
|
||||
// Include overdue entries so warm-resume diagnostics survive their removal.
|
||||
final missing = await gateway.missingSystemIds(pending);
|
||||
for (final old in (await gateway.ownedIds()).difference(
|
||||
desired.keys.toSet(),
|
||||
)) {
|
||||
@@ -135,6 +138,7 @@ class LocalNotificationService extends NotificationService {
|
||||
final fingerprint =
|
||||
'${request.fireAt.millisecondsSinceEpoch}/${request.title}/${request.body}/${request.exact}';
|
||||
if (pending.contains(entry.key) &&
|
||||
!missing.contains(entry.key) &&
|
||||
_fingerprints[entry.key] == fingerprint) {
|
||||
continue;
|
||||
}
|
||||
@@ -297,6 +301,20 @@ class PluginReminderGateway extends ReminderGateway {
|
||||
return owned;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Set<int>> missingSystemIds(Set<int> ids) async {
|
||||
if (ids.isEmpty) return {};
|
||||
try {
|
||||
final missing = await _system
|
||||
.invokeListMethod<int>('findMissingAlarmHandles', ids.toList())
|
||||
.timeout(const Duration(seconds: 2));
|
||||
return missing?.where(ids.contains).toSet() ?? {};
|
||||
} catch (_) {
|
||||
// Availability of this extra check must not block normal scheduling.
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> sendTestReminder({required bool scheduled}) async {
|
||||
final access = await permissions(request: false);
|
||||
|
||||
Reference in New Issue
Block a user