Revert "Revert "Improve sending message with mentions""
This reverts commit 0f043e36c4.
This commit is contained in:
@@ -500,9 +500,9 @@ ToolBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function postMessage() {
|
function postMessage() {
|
||||||
checkForFancyEffectsReason()
|
checkForFancyEffectsReason();
|
||||||
roomManager.actionsHandler.postMessage(inputField.text.trim(), attachmentPath,
|
roomManager.actionsHandler.postMessage(inputField.text.trim(), attachmentPath,
|
||||||
replyEventID, editEventId, inputField.userAutocompleted);
|
replyEventID, editEventId);
|
||||||
clearAttachment();
|
clearAttachment();
|
||||||
currentRoom.markAllMessagesAsRead();
|
currentRoom.markAllMessagesAsRead();
|
||||||
clear();
|
clear();
|
||||||
@@ -513,10 +513,6 @@ ToolBar {
|
|||||||
|
|
||||||
function autoComplete() {
|
function autoComplete() {
|
||||||
documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.displayText)
|
documentHandler.replaceAutoComplete(autoCompleteListView.currentItem.displayText)
|
||||||
// Unfortunally it doesn't
|
|
||||||
if (!autoCompleteListView.currentItem.isEmoji) {
|
|
||||||
inputField.userAutocompleted[autoCompleteListView.currentItem.displayText] = autoCompleteListView.currentItem.userId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -609,7 +605,6 @@ ToolBar {
|
|||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
inputField.clear()
|
inputField.clear()
|
||||||
inputField.userAutocompleted = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearEditReply() {
|
function clearEditReply() {
|
||||||
|
|||||||
@@ -159,16 +159,15 @@ void ActionsHandler::createRoom(const QString &name, const QString &topic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ActionsHandler::postMessage(const QString &text,
|
void ActionsHandler::postMessage(const QString &text,
|
||||||
const QString &attachementPath, const QString &replyEventId, const QString &editEventId,
|
const QString &attachementPath, const QString &replyEventId, const QString &editEventId)
|
||||||
const QVariantMap usernames)
|
|
||||||
{
|
{
|
||||||
QString rawText = text;
|
QString rawText = text;
|
||||||
QString cleanedText = text;
|
QString cleanedText = text;
|
||||||
|
|
||||||
for (const auto username : usernames.keys()) {
|
for (const auto *user : m_room->users()) {
|
||||||
const auto replacement = usernames.value(username);
|
const auto displayName = user->displayname(m_room);
|
||||||
cleanedText = cleanedText.replace(username,
|
cleanedText = cleanedText.replace(displayName,
|
||||||
"[" + username + "](https://matrix.to/#/" + replacement.toString() + ")");
|
"[" + displayName + "](https://matrix.to/#/" + user->id() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attachementPath.length() > 0) {
|
if (attachementPath.length() > 0) {
|
||||||
@@ -277,9 +276,6 @@ void ActionsHandler::postMessage(const QString &text,
|
|||||||
if (rawText.indexOf(partPrefix) == 0) {
|
if (rawText.indexOf(partPrefix) == 0) {
|
||||||
rawText = rawText.remove(0, partPrefix.length());
|
rawText = rawText.remove(0, partPrefix.length());
|
||||||
const QStringList splittedText = rawText.split(" ");
|
const QStringList splittedText = rawText.split(" ");
|
||||||
qDebug() << m_room;
|
|
||||||
qDebug() << "m_room";
|
|
||||||
qDebug() << splittedText;
|
|
||||||
if (splittedText.count() == 0 || splittedText[0].isEmpty()) {
|
if (splittedText.count() == 0 || splittedText[0].isEmpty()) {
|
||||||
// leave current room
|
// leave current room
|
||||||
m_connection->leaveRoom(m_room);
|
m_connection->leaveRoom(m_room);
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ public Q_SLOTS:
|
|||||||
///
|
///
|
||||||
/// This also interprets commands if any.
|
/// This also interprets commands if any.
|
||||||
void postMessage(const QString &text, const QString &attachementPath,
|
void postMessage(const QString &text, const QString &attachementPath,
|
||||||
const QString &replyEventId, const QString &editEventId,
|
const QString &replyEventId, const QString &editEventId);
|
||||||
const QVariantMap usernames);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Connection *m_connection = nullptr;
|
Connection *m_connection = nullptr;
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
|
|||||||
});
|
});
|
||||||
connect(this, &Room::fileTransferProgress, [=](const QString &id, qint64 progress, qint64 total) {
|
connect(this, &Room::fileTransferProgress, [=](const QString &id, qint64 progress, qint64 total) {
|
||||||
if (id == txnId) {
|
if (id == txnId) {
|
||||||
qDebug() << "Progress:" << progress << total;
|
|
||||||
setFileUploadingProgress(int(float(progress) / float(total) * 100));
|
setFileUploadingProgress(int(float(progress) / float(total) * 100));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -549,9 +548,7 @@ void NeoChatRoom::postMessage(const QString &text, MessageEventType type, const
|
|||||||
|
|
||||||
void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, MessageEventType type, const QString &replyEventId, const QString &relateToEventId)
|
void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, MessageEventType type, const QString &replyEventId, const QString &relateToEventId)
|
||||||
{
|
{
|
||||||
QString htmlWithLinks = html;
|
bool isRichText = Qt::mightBeRichText(html);
|
||||||
htmlWithLinks = htmlWithLinks.replace(QRegularExpression("@([^: ]*):([^ ]*\\.[^ ]*)"), "<a href=\"https://matrix.to/#/@$1:$2\">@$1:$2</a>");
|
|
||||||
bool isRichText = Qt::mightBeRichText(htmlWithLinks);
|
|
||||||
bool isReply = !replyEventId.isEmpty();
|
bool isReply = !replyEventId.isEmpty();
|
||||||
bool isEdit = !relateToEventId.isEmpty();
|
bool isEdit = !relateToEventId.isEmpty();
|
||||||
const auto replyIt = findInTimeline(replyEventId);
|
const auto replyIt = findInTimeline(replyEventId);
|
||||||
@@ -564,11 +561,15 @@ void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, Mess
|
|||||||
QJsonObject json {
|
QJsonObject json {
|
||||||
{"type", "m.room.message"},
|
{"type", "m.room.message"},
|
||||||
{"msgtype", msgTypeToString(type)},
|
{"msgtype", msgTypeToString(type)},
|
||||||
{"body", "* " + (isRichText ? text : htmlWithLinks)},
|
{"body", "* " + text},
|
||||||
|
{"format", "org.matrix.custom.html"},
|
||||||
|
{"formatted_body", html},
|
||||||
{"m.new_content",
|
{"m.new_content",
|
||||||
QJsonObject {
|
QJsonObject {
|
||||||
{"body", (isRichText ? text : htmlWithLinks)},
|
{"body", text},
|
||||||
{"msgtype", msgTypeToString(type)}
|
{"msgtype", msgTypeToString(type)},
|
||||||
|
{"format", "org.matrix.custom.html"},
|
||||||
|
{"formatted_body", html}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{"m.relates_to",
|
{"m.relates_to",
|
||||||
@@ -607,7 +608,7 @@ void NeoChatRoom::postHtmlMessage(const QString &text, const QString &html, Mess
|
|||||||
"\">In reply to</a> <a href=\"https://matrix.to/#/" +
|
"\">In reply to</a> <a href=\"https://matrix.to/#/" +
|
||||||
replyEvt.senderId() + "\">" + replyEvt.senderId() +
|
replyEvt.senderId() + "\">" + replyEvt.senderId() +
|
||||||
"</a><br>" + eventToString(replyEvt, Qt::RichText) +
|
"</a><br>" + eventToString(replyEvt, Qt::RichText) +
|
||||||
"</blockquote></mx-reply>" + (isRichText ? htmlWithLinks : text)
|
"</blockquote></mx-reply>" + (isRichText ? html : text)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|||||||
Reference in New Issue
Block a user