From d37538b69f41ae4cc7b6db97a6caffc7cd92011c Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Mon, 28 Sep 2026 09:49:20 -0400 Subject: [PATCH] gate pop behind canPop --- lib/widgets/pages/chat.dart | 6 ++---- lib/widgets/sidebar.dart | 9 +++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/widgets/pages/chat.dart b/lib/widgets/pages/chat.dart index 186dfa2..d3886d3 100644 --- a/lib/widgets/pages/chat.dart +++ b/lib/widgets/pages/chat.dart @@ -25,7 +25,7 @@ class const ChatPage({super.key}) extends HookConsumerWidget { body: initComplete ? Row( children: [ - if (isDesktop) Sidebar(isDesktop: isDesktop), + if (isDesktop) Sidebar(), Expanded( child: Consumer( builder: (context, ref, _) { @@ -50,9 +50,7 @@ class const ChatPage({super.key}) extends HookConsumerWidget { children: [Loading(), Text("Syncing...")], ), ), - drawer: isDesktop || !initComplete - ? null - : Sidebar(isDesktop: isDesktop), + drawer: isDesktop || !initComplete ? null : Sidebar(), ), ); }, diff --git a/lib/widgets/sidebar.dart b/lib/widgets/sidebar.dart index cc6d441..c6fede9 100644 --- a/lib/widgets/sidebar.dart +++ b/lib/widgets/sidebar.dart @@ -16,8 +16,7 @@ import "package:nexus/widgets/room_menu.dart"; // Needed for navigation_rail_m3e (#65). import "package:flutter/material.dart" as old_mat; -class const Sidebar({required final bool isDesktop, super.key}) - extends HookConsumerWidget { +class const Sidebar({super.key}) extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final selectedSpaceProvider = KeyController.provider( @@ -193,7 +192,8 @@ class const Sidebar({required final bool isDesktop, super.key}) IconButton( tooltip: "Open notifications", onPressed: () { - if (!isDesktop) Navigator.of(context).pop(); + if (Navigator.of(context).canPop()) + Navigator.of(context).pop(); Navigator.of(context).push( MaterialPageRoute( builder: (_) => NotificationsPage(), @@ -309,7 +309,8 @@ class const Sidebar({required final bool isDesktop, super.key}) selectedRoomIdNotifier.set( children[value].metadata?.id, // ); - if (!isDesktop) Navigator.of(context).pop(); + if (Navigator.of(context).canPop()) + Navigator.of(context).pop(); }, ), ),