diff --git a/resources/qml/TimelineView.qml b/resources/qml/TimelineView.qml index 99d14685..7ece08e2 100644 --- a/resources/qml/TimelineView.qml +++ b/resources/qml/TimelineView.qml @@ -110,6 +110,7 @@ Page { flow.sender = false; flow.deviceId = deviceId; flow.tranId = transactionId; + deviceVerificationList.add(flow.tranId); var dialog = deviceVerificationDialog.createObject(timelineRoot, {flow: flow,sender: false}); dialog.show(); diff --git a/resources/qml/device-verification/DeviceVerification.qml b/resources/qml/device-verification/DeviceVerification.qml index 1a3d1432..03fc5055 100644 --- a/resources/qml/device-verification/DeviceVerification.qml +++ b/resources/qml/device-verification/DeviceVerification.qml @@ -30,7 +30,11 @@ ApplicationWindow { implicitHeight: currentItem.implicitHeight } - onClosing: stack.replace(newVerificationRequest) + onClosing: { + flow.cancelVerification(); + deviceVerificationList.remove(flow.tranId); + delete flow; + } property var flow Connections { @@ -78,7 +82,7 @@ ApplicationWindow { onClicked: { dialog.close(); flow.cancelVerification(); - // deviceVerificationList.remove(flow.tranId); + deviceVerificationList.remove(flow.tranId); delete flow; } } @@ -135,7 +139,7 @@ ApplicationWindow { onClicked: { dialog.close(); flow.cancelVerification(); - // deviceVerificationList.remove(flow.tranId); + deviceVerificationList.remove(flow.tranId); delete flow; } } @@ -179,7 +183,7 @@ ApplicationWindow { onClicked: { dialog.close(); flow.cancelVerification(); - // deviceVerificationList.remove(flow.tranId); + deviceVerificationList.remove(flow.tranId); delete flow; } } @@ -230,7 +234,7 @@ ApplicationWindow { onClicked: { dialog.close(); flow.cancelVerification(); - // deviceVerificationList.remove(flow.tranId); + deviceVerificationList.remove(flow.tranId); delete flow; } } @@ -369,7 +373,7 @@ ApplicationWindow { onClicked: { dialog.close(); flow.cancelVerification(); - // deviceVerificationList.remove(flow.tranId); + deviceVerificationList.remove(flow.tranId); delete flow; } } @@ -413,7 +417,7 @@ ApplicationWindow { onClicked: { dialog.close(); flow.cancelVerification(); - // deviceVerificationList.remove(flow.tranId); + deviceVerificationList.remove(flow.tranId); delete flow; } } @@ -451,7 +455,7 @@ ApplicationWindow { text: "Close" onClicked: { dialog.close() - // deviceVerificationList.remove(flow.tranId); + deviceVerificationList.remove(flow.tranId); delete flow; } } @@ -485,8 +489,8 @@ ApplicationWindow { Layout.alignment: Qt.AlignRight text: "Close" onClicked: { - dialog.close() - // deviceVerificationList.remove(flow.tranId); + dialog.close(); + deviceVerificationList.remove(flow.tranId); delete flow; } } @@ -521,7 +525,7 @@ ApplicationWindow { text: "Close" onClicked: { dialog.close() - // deviceVerificationList.remove(flow.tranId); + deviceVerificationList.remove(flow.tranId); delete flow; } } diff --git a/src/DeviceVerificationFlow.cpp b/src/DeviceVerificationFlow.cpp index 0de94c50..db76aeb1 100644 --- a/src/DeviceVerificationFlow.cpp +++ b/src/DeviceVerificationFlow.cpp @@ -1,7 +1,6 @@ #include "DeviceVerificationFlow.h" #include "ChatPage.h" #include "Logging.h" -#include "Utils.h" #include #include @@ -162,7 +161,10 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *) } if (msg.content.keys == this->sas->calculate_mac(key_string, info + "KEY_IDS")) { - this->sendVerificationDone(); + // uncomment this in future to be compatible with the + // MSC2366 this->sendVerificationDone(); and remoeve the + // below line + emit this->deviceVerified(); } else { this->cancelVerification(); } diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 7d016cbd..234b0bb6 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -26,26 +26,17 @@ namespace msgs = mtx::events::msg; void DeviceVerificationList::add(QString tran_id) { - this->dv_list.push_back(tran_id); + this->dv_list.append(tran_id); } void DeviceVerificationList::remove(QString tran_id) { - for (QVector::iterator it = 0; it != (this->dv_list).end(); ++it) { - if (*it == tran_id) { - this->dv_list.erase(it); - break; - } - } + this->dv_list.removeOne(tran_id); } bool DeviceVerificationList::exist(QString tran_id) { - for (int i = 0; i < (this->dv_list).size(); ++i) { - if (dv_list[i] == tran_id) - return true; - } - return false; + return this->dv_list.contains(tran_id); } void @@ -183,7 +174,7 @@ TimelineViewManager::TimelineViewManager(QSharedPointer userSettin msg.content.methods.end(), mtx::events::msg::VerificationMethods::SASv1) != msg.content.methods.end()) { - flow->sendVerificationReady(); + // flow->sendVerificationReady(); emit newDeviceVerificationRequest( std::move(flow), QString::fromStdString(msg.content.transaction_id), diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 946461f9..8af6d137 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include #include @@ -31,7 +32,7 @@ public: Q_INVOKABLE bool exist(QString tran_id); private: - QVector dv_list; + QLinkedList dv_list; }; class TimelineViewManager : public QObject