fix: jump cannot work properly when there are multi users

This commit is contained in:
ShootingStarDragons 2025-11-18 23:59:36 +09:00
commit 940d3e62db
4 changed files with 17 additions and 2 deletions

View file

@ -147,8 +147,8 @@ extension LocalNotificationsExtension on MatrixState {
);
break;
case DesktopNotificationActions.openChat:
if (userId != null) {
Matrix.of(context).setActiveClientWithUserId(userId);
if (userId != null && controller != null) {
controller!.setActiveClientWithUserId(userId);
}
FluffyChatApp.router.go('/rooms/${event.room.id}');

View file

@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@ -70,6 +71,7 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
bool? loginRegistrationSupported;
BackgroundPush? backgroundPush;
ChatListController? controller;
Client get client {
if (_activeClient < 0 || _activeClient >= widget.clients.length) {
@ -100,6 +102,9 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
Logs().w('Tried to set an unknown user $userId as active');
}
}
void setController(ChatListController controller) {
this.controller = controller;
}
void setActiveClient(Client? cl) {
final i = widget.clients.indexWhere((c) => c == cl);