Page MenuHomePhorge

D90.1732347244.diff
No OneTemporary

Size
6 KB
Referenced Files
None
Subscribers
None

D90.1732347244.diff

diff --git a/src/contents/ui/room-settings/RoomSettingsPage.qml b/src/contents/ui/room-settings/RoomSettingsPage.qml
--- a/src/contents/ui/room-settings/RoomSettingsPage.qml
+++ b/src/contents/ui/room-settings/RoomSettingsPage.qml
@@ -10,6 +10,8 @@
import org.kde.kirigami 2.20 as Kirigami
+import moe.kazv.mxc.kazv 0.0 as MK
+
import '../matrix-helpers.js' as Helpers
import '..' as Kazv
@@ -177,6 +179,16 @@
confirmLeaveOverlay.open();
}
}
+
+ Button {
+ objectName: 'forgetRoomButton'
+ text: l10n.get('room-forget-action')
+ Layout.fillWidth: true
+ visible: room.membership === MK.MatrixRoom.Leave
+ onClicked: {
+ confirmForgetOverlay.open();
+ }
+ }
}
property var confirmLeaveOverlay: Kazv.ConfirmationOverlay {
@@ -200,4 +212,26 @@
}
}
}
+
+ property var confirmForgetOverlay: Kazv.ConfirmationOverlay {
+ objectName: 'confirmForgetRoomPopup'
+ parent: roomSettingsPage.overlay
+ title: l10n.get('room-forget-confirm-popup-title')
+ message: l10n.get('room-forget-confirm-popup-message')
+ confirmActionText: l10n.get('room-forget-confirm-popup-confirm-action')
+ cancelActionText: l10n.get('room-forget-confirm-popup-cancel-action')
+
+ onAccepted: forgetRoomHandler.call()
+ }
+
+ property var forgetRoomHandler: Kazv.AsyncHandler {
+ trigger: () => room.forgetRoom()
+ onResolved: (success, data) => {
+ if (success) {
+ showPassiveNotification(l10n.get('forget-room-success-prompt', { room: room.roomId }));
+ } else {
+ showPassiveNotification(l10n.get('forget-room-failed-prompt', { room: room.roomId, errorCode: data.errorCode, errorMsg: data.error }));
+ }
+ }
+ }
}
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
@@ -93,6 +93,12 @@
room-leave-confirm-popup-confirm-action = 离开
room-leave-confirm-popup-cancel-action = 留下
+room-forget-action = 忘记房间
+room-forget-confirm-popup-title = 忘记房间
+room-forget-confirm-popup-message = 你确定要忘记这个房间吗?
+room-forget-confirm-popup-confirm-action = 忘记
+room-forget-confirm-popup-cancel-action = 取消
+
send-message-box-input-placeholder = 在此输入您的讯息...
send-message-box-send = 发送
send-message-box-send-file = 发送文件
@@ -226,6 +232,9 @@
leave-room-success-prompt = 成功离开房间 { $room }。
leave-room-failed-prompt = 无法离开房间 { $room }。错误代码:{ $errorCode }。错误讯息:{ $errorMsg }。
+forget-room-success-prompt = 成功忘记房间 { $room }。
+forget-room-failed-prompt = 无法忘记房间 { $room }。错误代码: { $errorCode }。错误讯息: { $errorMsg }。
+
device-trust-level-unseen = 未曾见过
device-trust-level-seen = 见过
device-trust-level-verified = 已验证
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
@@ -93,6 +93,12 @@
room-leave-confirm-popup-confirm-action = Leave
room-leave-confirm-popup-cancel-action = Stay
+room-forget-action = Forget room
+room-forget-confirm-popup-title = Forgetting room
+room-forget-confirm-popup-message = Are you sure you want to forget this room?
+room-forget-confirm-popup-confirm-action = Forget
+room-forget-confirm-popup-cancel-action = Cancel
+
send-message-box-input-placeholder = Type your message here...
send-message-box-send = Send
send-message-box-send-file = Send file
@@ -247,6 +253,9 @@
leave-room-success-prompt = Successfully left room { $room }.
leave-room-failed-prompt = Unable to leave room { $room }. Error code: { $errorCode }. Error message: { $errorMsg }.
+forget-room-success-prompt = Successfully forget room { $room }.
+forget-room-failed-prompt = Unable to forget room { $room }. Error code: { $errorCode }. Error message: { $errorMsg }.
+
device-trust-level-unseen = Unseen
device-trust-level-seen = Seen
device-trust-level-verified = Verified
diff --git a/src/matrix-room.hpp b/src/matrix-room.hpp
--- a/src/matrix-room.hpp
+++ b/src/matrix-room.hpp
@@ -105,6 +105,8 @@
Q_INVOKABLE MatrixPromise *leaveRoom() const;
+ Q_INVOKABLE MatrixPromise *forgetRoom() const;
+
Q_INVOKABLE MatrixRoomMemberListModel *members() const;
Q_INVOKABLE MatrixRoomMemberListModel *bannedMembers() const;
diff --git a/src/matrix-room.cpp b/src/matrix-room.cpp
--- a/src/matrix-room.cpp
+++ b/src/matrix-room.cpp
@@ -342,6 +342,11 @@
return new MatrixPromise(m_room.leave());
}
+MatrixPromise *MatrixRoom::forgetRoom() const
+{
+ return new MatrixPromise(m_room.forget());
+}
+
MatrixRoomMember *MatrixRoom::memberAt(int index) const
{
return new MatrixRoomMember(m_room.memberEventByCursor(
diff --git a/src/tests/quick-tests/tst_RoomSettingsPage.qml b/src/tests/quick-tests/tst_RoomSettingsPage.qml
--- a/src/tests/quick-tests/tst_RoomSettingsPage.qml
+++ b/src/tests/quick-tests/tst_RoomSettingsPage.qml
@@ -33,6 +33,15 @@
encrypted: true,
})
+ property var roomLeft: Helpers.factory.room({
+ membership: MK.MatrixRoom.Leave,
+ forgetRoom: mockHelper.promise(),
+ })
+
+ property var roomJoined: Helpers.factory.room({
+ membership: MK.MatrixRoom.Join
+ })
+
property var showPassiveNotification: mockHelper.noop()
property var l10n: Helpers.fluentMock
@@ -51,6 +60,16 @@
id: pageEncrypted
room: item.roomEncrypted
}
+
+ KazvRS.RoomSettingsPage {
+ id: pageLeft
+ room: item.roomLeft
+ }
+
+ KazvRS.RoomSettingsPage {
+ id: pageJoined
+ room: item.roomJoined
+ }
}
TestCase {
@@ -58,6 +77,10 @@
name: 'RoomSettingsPageTest'
when: windowShown
+ function init() {
+ mockHelper.clearAll();
+ }
+
function test_encryptionIndicator() {
compare(findChild(pageUnencrypted, 'encryptionIndicator').text, l10n.get('room-settings-not-encrypted'));
verify(findChild(pageUnencrypted, 'enableEncryptionButton').visible);
@@ -74,5 +97,25 @@
roomUnencrypted.sendStateEvent.lastRetVal().resolve(true, {});
tryVerify(() => findChild(pageUnencrypted, 'enableEncryptionButton').enabled);
}
+
+ function test_forgetRoom() {
+ const forgetRoomButton = findChild(pageLeft, 'forgetRoomButton');
+ const confirmPopup = findChild(pageLeft, 'confirmForgetRoomPopup');
+ verify(forgetRoomButton.visible);
+ verify(!findChild(pageJoined, 'forgetRoomButton').visible);
+
+ confirmPopup.accepted();
+ tryVerify(() => roomLeft.forgetRoom.calledTimes() === 1);
+
+ roomLeft.forgetRoom.lastRetVal().resolve(true, {});
+ tryVerify(() => item.showPassiveNotification.calledTimes() === 1);
+ }
+
+ function test_forgetRoomFailure() {
+ const confirmPopup = findChild(pageLeft, 'confirmForgetRoomPopup');
+ confirmPopup.accepted();
+ roomLeft.forgetRoom.lastRetVal().resolve(false, {});
+ tryVerify(() => item.showPassiveNotification.calledTimes() === 1);
+ }
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 11:34 PM (14 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39099
Default Alt Text
D90.1732347244.diff (6 KB)

Event Timeline