Page MenuHomePhorge

D24.1732272251.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D24.1732272251.diff

diff --git a/src/contents/ui/MessageNotification.qml b/src/contents/ui/MessageNotification.qml
--- a/src/contents/ui/MessageNotification.qml
+++ b/src/contents/ui/MessageNotification.qml
@@ -12,4 +12,9 @@
eventId: 'message'
text: 'test text'
title: 'test title'
+ property var roomId
+ defaultAction: l10n.get('notification-open')
+ onDefaultActivated: {
+ sdkVars.currentRoomId = roomId;
+ }
}
diff --git a/src/contents/ui/Notifier.qml b/src/contents/ui/Notifier.qml
--- a/src/contents/ui/Notifier.qml
+++ b/src/contents/ui/Notifier.qml
@@ -27,7 +27,11 @@
const senderName = sender.name || sender.userId || '';
if (matrixSdk.shouldNotify(event)) {
console.debug('Push rules say we should notify this');
- const notification = notificationComp.createObject(notifier);
+ const notification = notificationComp.createObject(
+ notifier,
+ {
+ roomId,
+ });
notification.eventId = matrixSdk.shouldPlaySound(event) ? 'message' : 'messageWithoutSound';
notification.title = Helpers.roomNameOrHeroes(room, l10n);
const message = event.content.body;
diff --git a/src/contents/ui/main.qml b/src/contents/ui/main.qml
--- a/src/contents/ui/main.qml
+++ b/src/contents/ui/main.qml
@@ -162,6 +162,11 @@
}
function activateRoomPage() {
+ // Go back to the first page. This ensures that the room page
+ // will always be the second page.
+ while (pageStack.currentIndex > 0) {
+ pageStack.goBack();
+ }
pageStack.push(Qt.resolvedUrl("RoomPage.qml"), {
roomId: root.sdkVars.currentRoomId,
});
diff --git a/src/l10n/cmn-Hans/100-ui.ftl b/src/l10n/cmn-Hans/100-ui.ftl
--- a/src/l10n/cmn-Hans/100-ui.ftl
+++ b/src/l10n/cmn-Hans/100-ui.ftl
@@ -247,6 +247,7 @@
notification-message = <b>{ $user }:</b> { $message }
notification-message-no-content = <b>{ $user }</b> 给你发了一条讯息。
+notification-open = 打开
user-page-power-level = 权限等级:{ $powerLevel }
user-page-edit-power-level-action = 编辑
diff --git a/src/l10n/en/100-ui.ftl b/src/l10n/en/100-ui.ftl
--- a/src/l10n/en/100-ui.ftl
+++ b/src/l10n/en/100-ui.ftl
@@ -268,6 +268,7 @@
notification-message = <b>{ $user }:</b> { $message }
notification-message-no-content = <b>{ $user }</b> sent you a message.
+notification-open = Open
user-page-power-level = Power level: { $powerLevel }
user-page-edit-power-level-action = Edit
diff --git a/src/tests/quick-tests/tst_Notifications.qml b/src/tests/quick-tests/tst_Notifications.qml
new file mode 100644
--- /dev/null
+++ b/src/tests/quick-tests/tst_Notifications.qml
@@ -0,0 +1,37 @@
+/*
+ * This file is part of kazv.
+ * SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import QtQuick 2.15
+import QtQuick.Layouts 1.15
+import QtTest 1.0
+
+import '../../contents/ui' as Kazv
+import 'test-helpers.js' as Helpers
+import 'test-helpers' as TestHelpers
+
+TestCase {
+ id: notificationsTest
+ name: 'NotificationsTest'
+ when: true
+
+ property var sdkVars: ({
+ currentRoomId: '',
+ })
+
+ Kazv.MessageNotification {
+ id: notification
+ roomId: '!foo:example.com'
+ }
+
+ function init() {
+ sdkVars.currentRoomId = '';
+ }
+
+ function test_messageNotification() {
+ notification.defaultActivated();
+ compare(sdkVars.currentRoomId, '!foo:example.com');
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 2:44 AM (12 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38812
Default Alt Text
D24.1732272251.diff (3 KB)

Event Timeline