diff options
author | Loren Burkholder <computersemiexpert@outlook.com> | 2023-03-06 19:21:23 -0500 |
---|---|---|
committer | Loren Burkholder <computersemiexpert@outlook.com> | 2023-04-08 18:59:17 -0400 |
commit | 0096226aebc6f3ab0ec122e92dab40be5a863ec9 (patch) | |
tree | 6b761d478291e949a99909b9d84fde087d21fa2d | |
parent | Translated using Weblate (German) (diff) | |
download | nheko-0096226aebc6f3ab0ec122e92dab40be5a863ec9.tar.xz |
Implement unknown msgtype functionality
-rw-r--r-- | resources/qml/delegates/MessageDelegate.qml | 16 | ||||
-rw-r--r-- | src/Utils.cpp | 3 | ||||
-rw-r--r-- | src/Utils.h | 3 | ||||
-rw-r--r-- | src/timeline/TimelineModel.cpp | 17 | ||||
-rw-r--r-- | src/timeline/TimelineModel.h | 3 |
5 files changed, 36 insertions, 6 deletions
diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index d298fa4e..9126186e 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -51,7 +51,7 @@ Item { width: parent.width? parent.width: 0 // this should get rid of "cannot read property 'width' of null" DelegateChoice { - roleValue: MtxEvent.UnknownMessage + roleValue: MtxEvent.UnknownEvent Placeholder { typeString: d.typeString @@ -102,6 +102,20 @@ Item { } DelegateChoice { + roleValue: MtxEvent.UnknownMessage + + TextMessage { + formatted: d.formattedBody + body: d.body + isOnlyEmoji: d.isOnlyEmoji + isReply: d.isReply + keepFullText: d.keepFullText + metadataWidth: d.metadataWidth + } + + } + + DelegateChoice { roleValue: MtxEvent.ConfettiMessage TextMessage { diff --git a/src/Utils.cpp b/src/Utils.cpp index c5b2abd1..eca5cb29 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -221,6 +221,7 @@ utils::getMessageDescription(const TimelineEvent &event, using Image = mtx::events::RoomEvent<mtx::events::msg::Image>; using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>; using Text = mtx::events::RoomEvent<mtx::events::msg::Text>; + using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>; using Video = mtx::events::RoomEvent<mtx::events::msg::Video>; using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>; using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>; @@ -241,6 +242,8 @@ utils::getMessageDescription(const TimelineEvent &event, return createDescriptionInfo<Notice>(event, localUser, displayName); } else if (std::holds_alternative<Text>(event)) { return createDescriptionInfo<Text>(event, localUser, displayName); + } else if (std::holds_alternative<Unknown>(event)) { + return createDescriptionInfo<Unknown>(event, localUser, displayName); } else if (std::holds_alternative<Video>(event)) { return createDescriptionInfo<Video>(event, localUser, displayName); } else if (std::holds_alternative<Confetti>(event)) { diff --git a/src/Utils.h b/src/Utils.h index 2bf01f84..c16d5a13 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -102,6 +102,7 @@ messageDescription(const QString &username = QString(), using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>; using Sticker = mtx::events::Sticker; using Text = mtx::events::RoomEvent<mtx::events::msg::Text>; + using Unknown = mtx::events::RoomEvent<mtx::events::msg::Unknown>; using Video = mtx::events::RoomEvent<mtx::events::msg::Video>; using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>; using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>; @@ -149,7 +150,7 @@ messageDescription(const QString &username = QString(), return QCoreApplication::translate("message-description sent:", "%1 sent a notification") .arg(username); - } else if (std::is_same<T, Text>::value) { + } else if (std::is_same<T, Text>::value || std::is_same<T, Unknown>::value) { if (isLocal) return QCoreApplication::translate("message-description sent:", "You: %1").arg(body); else diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp index cb9fb7fa..ae6ecc9a 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp @@ -84,6 +84,11 @@ struct RoomEventType return qml_mtx_events::EventType::TextMessage; } constexpr qml_mtx_events::EventType + operator()(const mtx::events::Event<mtx::events::msg::Unknown> &) + { + return qml_mtx_events::EventType::UnknownMessage; + } + constexpr qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::msg::Video> &) { return qml_mtx_events::EventType::VideoMessage; @@ -203,7 +208,7 @@ qml_mtx_events::toRoomEventType(mtx::events::EventType e) case EventType::RoomMember: return qml_mtx_events::EventType::Member; case EventType::RoomMessage: - return qml_mtx_events::EventType::UnknownMessage; + return qml_mtx_events::EventType::UnknownEvent; case EventType::RoomName: return qml_mtx_events::EventType::Name; case EventType::RoomPowerLevels: @@ -239,7 +244,7 @@ qml_mtx_events::toRoomEventType(mtx::events::EventType e) case EventType::Unsupported: return qml_mtx_events::EventType::Unsupported; default: - return qml_mtx_events::EventType::UnknownMessage; + return qml_mtx_events::EventType::UnknownEvent; } } @@ -369,9 +374,10 @@ qml_mtx_events::fromRoomEventType(qml_mtx_events::EventType t) case qml_mtx_events::LocationMessage: case qml_mtx_events::NoticeMessage: case qml_mtx_events::TextMessage: + case qml_mtx_events::UnknownMessage: case qml_mtx_events::VideoMessage: case qml_mtx_events::Redacted: - case qml_mtx_events::UnknownMessage: + case qml_mtx_events::UnknownEvent: case qml_mtx_events::KeyVerificationRequest: case qml_mtx_events::KeyVerificationStart: case qml_mtx_events::KeyVerificationMac: @@ -1077,6 +1083,11 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline) std::get<RoomEvent<mtx::events::msg::Text>>(e).content.body); msg.contains("🎉") || msg.contains("🎊")) needsSpecialEffects_ = true; + } else if (std::holds_alternative<RoomEvent<mtx::events::msg::Unknown>>(e)) { + if (auto msg = QString::fromStdString( + std::get<RoomEvent<mtx::events::msg::Unknown>>(e).content.body); + msg.contains("🎉") || msg.contains("🎊")) + needsSpecialEffects_ = true; } else if (std::holds_alternative<RoomEvent<mtx::events::msg::Confetti>>(e)) needsSpecialEffects_ = true; } diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h index 03cb9ecb..d71012c1 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h @@ -106,9 +106,10 @@ enum EventType LocationMessage, NoticeMessage, TextMessage, + UnknownMessage, VideoMessage, Redacted, - UnknownMessage, + UnknownEvent, KeyVerificationRequest, KeyVerificationStart, KeyVerificationMac, |