Mark chats seen after user interaction
Prevent passive open, restored, or unfocused chats from clearing notifications. Track qualifying focused interactions and cover passive and active seen-watermark behavior with tests and notes.
This commit is contained in:
@@ -46,6 +46,23 @@ class ServerConnections extends ChangeNotifier {
|
||||
return true;
|
||||
}
|
||||
|
||||
String? _chatOpenId;
|
||||
|
||||
/// A chat the user opened from a notification. The tap is the user's own
|
||||
/// interaction, so the chat it opens is read; a route restored without a tap
|
||||
/// never sets this.
|
||||
void requestChatOpen(String sessionId) {
|
||||
_chatOpenId = sessionId;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Consumes the notification open of [sessionId], once.
|
||||
bool takeChatOpenIntent(String sessionId) {
|
||||
if (sessionId.isEmpty || sessionId != _chatOpenId) return false;
|
||||
_chatOpenId = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Keep the intent outside the app that selecting another machine disposes.
|
||||
Future<bool> requestNewChat(String id) async {
|
||||
if (_busy || _disposed) return false;
|
||||
|
||||
Reference in New Issue
Block a user