Files
Client/lib/notification/notification_tasks.dart
T
2026-05-05 21:44:23 +02:00

31 lines
1.1 KiB
Dart

import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_app_badge/flutter_app_badge.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../routing/app_routes.dart';
import '../state/app/modules/chat/bloc/chat_bloc.dart';
import '../state/app/modules/chatList/bloc/chat_list_bloc.dart';
class NotificationTasks {
static void updateBadgeCount(RemoteMessage notification) {
FlutterAppBadge.count(int.parse(notification.data['unreadCount'] ?? '0'));
}
static void updateProviders(BuildContext context) {
context.read<ChatListBloc>().refresh();
context.read<ChatBloc>().refresh();
}
/// Switches to the Talk tab. If [chatToken] is provided, also schedules
/// the matching chat to be opened automatically once the chat list view
/// resolves the token (handled inside [ChatList]).
static void navigateToTalk(BuildContext context, {String? chatToken}) {
if (chatToken != null && chatToken.isNotEmpty) {
AppRoutes.openChatByToken(context, chatToken);
} else {
AppRoutes.goToTalkTab(context);
}
}
}