diff --git a/flutter/lib/mobile/pages/home_page.dart b/flutter/lib/mobile/pages/home_page.dart index f902f6743..5713830bc 100644 --- a/flutter/lib/mobile/pages/home_page.dart +++ b/flutter/lib/mobile/pages/home_page.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_hbb/common/widgets/overlay.dart'; import 'package:flutter_hbb/mobile/pages/server_page.dart'; import 'package:flutter_hbb/mobile/pages/settings_page.dart'; import 'package:get/get.dart'; @@ -25,6 +26,7 @@ class _HomePageState extends State { var _selectedIndex = 0; int get selectedIndex => _selectedIndex; final List _pages = []; + final _blockableOverlayState = BlockableOverlayState(); void refreshPages() { setState(() { @@ -36,6 +38,7 @@ class _HomePageState extends State { void initState() { super.initState(); initPages(); + _blockableOverlayState.applyFfi(gFFI); } void initPages() { diff --git a/flutter/lib/mobile/pages/remote_page.dart b/flutter/lib/mobile/pages/remote_page.dart index a769fd187..c6fc1baa1 100644 --- a/flutter/lib/mobile/pages/remote_page.dart +++ b/flutter/lib/mobile/pages/remote_page.dart @@ -43,8 +43,6 @@ class _RemotePageState extends State { double _mouseScrollIntegral = 0; // mouse scroll speed controller Orientation? _currentOrientation; - final _blockableOverlayState = BlockableOverlayState(); - final keyboardVisibilityController = KeyboardVisibilityController(); late final StreamSubscription keyboardSubscription; final FocusNode _mobileFocusNode = FocusNode(); @@ -70,7 +68,6 @@ class _RemotePageState extends State { gFFI.qualityMonitorModel.checkShowQualityMonitor(sessionId); keyboardSubscription = keyboardVisibilityController.onChange.listen(onSoftKeyboardChanged); - _blockableOverlayState.applyFfi(gFFI); initSharedStates(widget.id); gFFI.chatModel .changeCurrentKey(MessageKey(widget.id, ChatModel.clientModeID)); diff --git a/flutter/lib/models/chat_model.dart b/flutter/lib/models/chat_model.dart index e44a694d4..48476951f 100644 --- a/flutter/lib/models/chat_model.dart +++ b/flutter/lib/models/chat_model.dart @@ -70,6 +70,7 @@ class ChatModel with ChangeNotifier { TextEditingController textController = TextEditingController(); RxInt mobileUnreadSum = 0.obs; + MessageKey? latestReceivedKey; @override void dispose() { @@ -194,6 +195,12 @@ class ChatModel with ChangeNotifier { final overlayState = _blockableOverlayState?.state; if (overlayState == null) return; + if (isMobile && + !gFFI.chatModel.currentKey.isOut && // not in remote page + gFFI.chatModel.latestReceivedKey != null) { + gFFI.chatModel.changeCurrentKey(gFFI.chatModel.latestReceivedKey!); + gFFI.chatModel.mobileClearClientUnread(gFFI.chatModel.currentKey.connId); + } final overlay = OverlayEntry(builder: (context) { return Listener( onPointerDown: (_) { @@ -337,7 +344,7 @@ class ChatModel with ChangeNotifier { final messagekey = MessageKey(peerId, id); // mobile: first message show overlay icon - if (!isDesktop && chatIconOverlayEntry == null && id == clientModeID) { + if (!isDesktop && chatIconOverlayEntry == null) { showChatIconOverlay(); } // show chat page @@ -404,6 +411,7 @@ class ChatModel with ChangeNotifier { _currentKey = messagekey; mobileClearClientUnread(messagekey.connId); } + latestReceivedKey = messagekey; notifyListeners(); }