fixed notification taps being ignored when they cold-started the app

This commit is contained in:
2026-09-27 14:38:48 +02:00
parent 2ca9feb49a
commit 1fd6264d10
7 changed files with 146 additions and 59 deletions
+6 -22
View File
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../push/push_message_handler.dart';
import '../routing/app_routes.dart';
import '../push/push_target.dart';
import '../state/app/modules/chat/bloc/chat_bloc.dart';
import '../state/app/modules/chat_list/bloc/chat_list_bloc.dart';
import '../utils/debouncer.dart';
@@ -51,18 +51,15 @@ class NotificationController {
RemoteMessage message,
BuildContext context,
) async {
final newsletterId = _extractNewsletterId(message);
if (newsletterId != null) {
AppRoutes.openNewsletterById(
final target = resolvePushTarget(message.data);
if (target != null) {
NotificationTasks.openPushTarget(
context,
id: newsletterId,
target,
title: message.notification?.title,
);
} else {
NotificationTasks.navigateToTalk(
context,
chatToken: _extractChatToken(message),
);
NotificationTasks.navigateToTalk(context);
}
NotificationTasks.updateProviders(context);
unawaited(NotificationTasks.refreshBadge());
@@ -77,17 +74,4 @@ class NotificationController {
);
});
}
static String? _extractChatToken(RemoteMessage message) {
for (final key in const ['chatToken', 'token', 'roomToken']) {
final value = message.data[key];
if (value is String && value.isNotEmpty) return value;
}
return null;
}
static String? _extractNewsletterId(RemoteMessage message) {
final value = message.data['newsletterId'];
return value is String && value.isNotEmpty ? value : null;
}
}