Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Guard search callbacks after dispose

ashilkn17cf48ab33ed
diff --git a/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart b/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart
index dfb1b2398e..ed54aa72fb 100644
--- a/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/search/search_widget.dart
@@ -56,11 +56,12 @@ class SearchWidgetState extends State<SearchWidget> {
super.initState();
focusNode = FocusNode();
focusNode.addListener(() {
+ if (!mounted) {
+ return;
+ }
_syncSearchBackNotifier();
_notifyActiveChanged();
- if (mounted) {
- setState(() {});
- }
+ setState(() {});
});
_tabChangedEvent = Bus.instance.on<TabChangedEvent>().listen((event) async {
if (!mounted) {
@@ -89,6 +90,9 @@ class SearchWidgetState extends State<SearchWidget> {
_clearAndUnfocusSearchBar = Bus.instance
.on<ClearAndUnfocusSearchBar>()
.listen((event) {
+ if (!mounted) {
+ return;
+ }
textController.clear();
focusNode.unfocus();
_syncSearchBackNotifier(false);