import 'package:flutter/foundation.dart'; /// Pending UI removals are scoped to an account as well as a chat. class PendingMessageDeletions extends ChangeNotifier { PendingMessageDeletions(); static final instance = PendingMessageDeletions(); final Map<(int, int), Set> _pending = {}; bool contains(int accountId, int chatId, String id) => _pending[(accountId, chatId)]?.contains(id) ?? false; void hold(int accountId, int chatId, Iterable ids) { _pending.putIfAbsent((accountId, chatId), () => {}).addAll(ids); notifyListeners(); } void release(int accountId, int chatId, Iterable ids) { final pending = _pending[(accountId, chatId)]; if (pending == null) return; pending.removeAll(ids); if (pending.isEmpty) _pending.remove((accountId, chatId)); notifyListeners(); } }