refactor: active room ID now only in defined in the path

This commit is contained in:
Christian Pauly 2021-06-06 10:00:52 +02:00
parent dca23d3819
commit 18abb21cdb
5 changed files with 8 additions and 8 deletions

View file

@ -204,7 +204,6 @@ class ChatController extends State<Chat> {
void dispose() {
timeline?.cancelSubscriptions();
timeline = null;
matrix.client.activeRoomId = '';
super.dispose();
}

View file

@ -47,7 +47,6 @@ class ChatView extends StatelessWidget {
),
);
}
controller.matrix.client.activeRoomId = controller.roomId;
if (controller.room.membership == Membership.invite) {
showFutureLoadingDialog(

View file

@ -586,8 +586,10 @@ class BackgroundPush {
await room.postLoad();
final event = await client.database.getEventById(client.id, eventId, room);
if (((client.activeRoomId?.isNotEmpty ?? false) &&
client.activeRoomId == room.id &&
final activeRoomId = router.currentState.pathParameters['roomid'];
if (((activeRoomId?.isNotEmpty ?? false) &&
activeRoomId == room.id &&
client.syncPresence == null) ||
(event != null && room.notificationCount == 0)) {
return;

View file

@ -7,9 +7,6 @@ import '../famedlysdk_store.dart';
class FluffyClient extends Client {
static FluffyClient _instance;
/// The ID of the currently active room, if there is one. May be null or emtpy
String activeRoomId;
factory FluffyClient({testMode = false}) {
_instance ??= FluffyClient._internal(testMode: testMode);
return _instance;

View file

@ -204,9 +204,12 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
bool webHasFocus = true;
String get activeRoomId =>
VRouter.of(navigatorContext).pathParameters['roomid'];
void _showLocalNotification(EventUpdate eventUpdate) async {
final roomId = eventUpdate.roomID;
if (webHasFocus && client.activeRoomId == roomId) return;
if (webHasFocus && activeRoomId == roomId) return;
final room = client.getRoomById(roomId);
if (room.notificationCount == 0) return;
final event = Event.fromJson(eventUpdate.content, room);