mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +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"
|
width: parent.width? parent.width: 0 // this should get rid of "cannot read property 'width' of null"
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: MtxEvent.UnknownMessage
|
roleValue: MtxEvent.UnknownEvent
|
||||||
|
|
||||||
Placeholder {
|
Placeholder {
|
||||||
typeString: d.typeString
|
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 {
|
DelegateChoice {
|
||||||
roleValue: MtxEvent.ConfettiMessage
|
roleValue: MtxEvent.ConfettiMessage
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,7 @@ utils::getMessageDescription(const TimelineEvent &event,
|
||||||
using Image = mtx::events::RoomEvent<mtx::events::msg::Image>;
|
using Image = mtx::events::RoomEvent<mtx::events::msg::Image>;
|
||||||
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
||||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
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 Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>;
|
using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>;
|
||||||
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||||
|
@ -241,6 +242,8 @@ utils::getMessageDescription(const TimelineEvent &event,
|
||||||
return createDescriptionInfo<Notice>(event, localUser, displayName);
|
return createDescriptionInfo<Notice>(event, localUser, displayName);
|
||||||
} else if (std::holds_alternative<Text>(event)) {
|
} else if (std::holds_alternative<Text>(event)) {
|
||||||
return createDescriptionInfo<Text>(event, localUser, displayName);
|
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)) {
|
} else if (std::holds_alternative<Video>(event)) {
|
||||||
return createDescriptionInfo<Video>(event, localUser, displayName);
|
return createDescriptionInfo<Video>(event, localUser, displayName);
|
||||||
} else if (std::holds_alternative<Confetti>(event)) {
|
} 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 Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
||||||
using Sticker = mtx::events::Sticker;
|
using Sticker = mtx::events::Sticker;
|
||||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
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 Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>;
|
using Confetti = mtx::events::RoomEvent<mtx::events::msg::Confetti>;
|
||||||
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||||
|
@ -149,7 +150,7 @@ messageDescription(const QString &username = QString(),
|
||||||
return QCoreApplication::translate("message-description sent:",
|
return QCoreApplication::translate("message-description sent:",
|
||||||
"%1 sent a notification")
|
"%1 sent a notification")
|
||||||
.arg(username);
|
.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)
|
if (isLocal)
|
||||||
return QCoreApplication::translate("message-description sent:", "You: %1").arg(body);
|
return QCoreApplication::translate("message-description sent:", "You: %1").arg(body);
|
||||||
else
|
else
|
||||||
|
|
|
@ -84,6 +84,11 @@ struct RoomEventType
|
||||||
return qml_mtx_events::EventType::TextMessage;
|
return qml_mtx_events::EventType::TextMessage;
|
||||||
}
|
}
|
||||||
constexpr qml_mtx_events::EventType
|
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> &)
|
operator()(const mtx::events::Event<mtx::events::msg::Video> &)
|
||||||
{
|
{
|
||||||
return qml_mtx_events::EventType::VideoMessage;
|
return qml_mtx_events::EventType::VideoMessage;
|
||||||
|
@ -203,7 +208,7 @@ qml_mtx_events::toRoomEventType(mtx::events::EventType e)
|
||||||
case EventType::RoomMember:
|
case EventType::RoomMember:
|
||||||
return qml_mtx_events::EventType::Member;
|
return qml_mtx_events::EventType::Member;
|
||||||
case EventType::RoomMessage:
|
case EventType::RoomMessage:
|
||||||
return qml_mtx_events::EventType::UnknownMessage;
|
return qml_mtx_events::EventType::UnknownEvent;
|
||||||
case EventType::RoomName:
|
case EventType::RoomName:
|
||||||
return qml_mtx_events::EventType::Name;
|
return qml_mtx_events::EventType::Name;
|
||||||
case EventType::RoomPowerLevels:
|
case EventType::RoomPowerLevels:
|
||||||
|
@ -239,7 +244,7 @@ qml_mtx_events::toRoomEventType(mtx::events::EventType e)
|
||||||
case EventType::Unsupported:
|
case EventType::Unsupported:
|
||||||
return qml_mtx_events::EventType::Unsupported;
|
return qml_mtx_events::EventType::Unsupported;
|
||||||
default:
|
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::LocationMessage:
|
||||||
case qml_mtx_events::NoticeMessage:
|
case qml_mtx_events::NoticeMessage:
|
||||||
case qml_mtx_events::TextMessage:
|
case qml_mtx_events::TextMessage:
|
||||||
|
case qml_mtx_events::UnknownMessage:
|
||||||
case qml_mtx_events::VideoMessage:
|
case qml_mtx_events::VideoMessage:
|
||||||
case qml_mtx_events::Redacted:
|
case qml_mtx_events::Redacted:
|
||||||
case qml_mtx_events::UnknownMessage:
|
case qml_mtx_events::UnknownEvent:
|
||||||
case qml_mtx_events::KeyVerificationRequest:
|
case qml_mtx_events::KeyVerificationRequest:
|
||||||
case qml_mtx_events::KeyVerificationStart:
|
case qml_mtx_events::KeyVerificationStart:
|
||||||
case qml_mtx_events::KeyVerificationMac:
|
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);
|
std::get<RoomEvent<mtx::events::msg::Text>>(e).content.body);
|
||||||
msg.contains("🎉") || msg.contains("🎊"))
|
msg.contains("🎉") || msg.contains("🎊"))
|
||||||
needsSpecialEffects_ = true;
|
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))
|
} else if (std::holds_alternative<RoomEvent<mtx::events::msg::Confetti>>(e))
|
||||||
needsSpecialEffects_ = true;
|
needsSpecialEffects_ = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,9 +106,10 @@ enum EventType
|
||||||
LocationMessage,
|
LocationMessage,
|
||||||
NoticeMessage,
|
NoticeMessage,
|
||||||
TextMessage,
|
TextMessage,
|
||||||
|
UnknownMessage,
|
||||||
VideoMessage,
|
VideoMessage,
|
||||||
Redacted,
|
Redacted,
|
||||||
UnknownMessage,
|
UnknownEvent,
|
||||||
KeyVerificationRequest,
|
KeyVerificationRequest,
|
||||||
KeyVerificationStart,
|
KeyVerificationStart,
|
||||||
KeyVerificationMac,
|
KeyVerificationMac,
|
||||||
|
|
Loading…
Reference in a new issue