From ce0014f84682d89a0ad426703de980a831bd6dbf Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Tue, 2 Sep 2025 19:06:43 -0400 Subject: [PATCH] Don't accidentally hide relevant error banners We use error banners for intermittent errors (failing to join a room), along with more long-standing/important errors (like going offline.) And due to the nature of how we manage banner visibility - for example, the online check could accidentally hide joining rooms errors which is pretty bad. To fix this, each error banner is assigned an id. All errors can still overwrite each other as they could before, but they can only hide banners of their own kind. --- src/app/qml/RoomPage.qml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/app/qml/RoomPage.qml b/src/app/qml/RoomPage.qml index 05bd98f2a..76dfa47bb 100644 --- a/src/app/qml/RoomPage.qml +++ b/src/app/qml/RoomPage.qml @@ -79,9 +79,9 @@ Kirigami.Page { if (root.currentRoom.tagNames.includes("m.server_notice")) { banner.text = i18nc("@info", "This room contains official messages from your homeserver.") - banner.visible = true; + banner.show("message"); } else { - banner.visible = false; + banner.hideIf("message"); } } @@ -90,10 +90,10 @@ Kirigami.Page { function onIsOnlineChanged() { if (!root.currentRoom.connection.isOnline) { banner.text = i18nc("@info:status", "NeoChat is offline. Please check your network connection."); - banner.visible = true; banner.type = Kirigami.MessageType.Error; + banner.show("offline"); } else { - banner.visible = false; + banner.hideIf("offline"); } } } @@ -101,9 +101,23 @@ Kirigami.Page { header: Kirigami.InlineMessage { id: banner + // Used to keep track of messages so we can hide the right one at the right time + property string messageId + showCloseButton: true visible: false position: Kirigami.InlineMessage.Position.Header + + function show(msgid: string): void { + messageId = msgid; + visible = true; + } + + function hideIf(msgid: string): void { + if (messageId == msgid) { + visible = false; + } + } } Loader { @@ -204,7 +218,7 @@ Kirigami.Page { function onShowMessage(messageType, message) { banner.text = message; banner.type = messageType; - banner.visible = true; + banner.show("generic"); } function onShowEventSource(eventId) {