mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-21 18:50:47 +03:00
Implement unknown msgtype functionality
This commit is contained in:
parent
b0f3d39e1e
commit
0096226aeb
5 changed files with 36 additions and 6 deletions
|
@ -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
|
||||
|
@ -101,6 +101,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
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -106,9 +106,10 @@ enum EventType
|
|||
LocationMessage,
|
||||
NoticeMessage,
|
||||
TextMessage,
|
||||
UnknownMessage,
|
||||
VideoMessage,
|
||||
Redacted,
|
||||
UnknownMessage,
|
||||
UnknownEvent,
|
||||
KeyVerificationRequest,
|
||||
KeyVerificationStart,
|
||||
KeyVerificationMac,
|
||||
|
|
Loading…
Reference in a new issue