Fix the master show link preview setting and add back the per room setting

Title

BUG: 486126
This commit is contained in:
James Graham
2024-04-28 10:51:44 +00:00
parent 99d91c1e07
commit 0cf1d87b12
2 changed files with 12 additions and 4 deletions

View File

@@ -277,7 +277,9 @@ void MessageContentModel::updateComponents(bool isEditing)
m_components.append(componentsForType(eventHandler.messageComponentType())); m_components.append(componentsForType(eventHandler.messageComponentType()));
} }
addLinkPreviews(); if (m_room->urlPreviewEnabled()) {
addLinkPreviews();
}
endResetModel(); endResetModel();
} }
@@ -360,8 +362,9 @@ void MessageContentModel::addLinkPreviews()
if (LinkPreviewer::hasPreviewableLinks(component.content)) { if (LinkPreviewer::hasPreviewableLinks(component.content)) {
const auto links = LinkPreviewer::linkPreviews(component.content); const auto links = LinkPreviewer::linkPreviews(component.content);
for (qsizetype j = 0; j < links.size(); ++j) { for (qsizetype j = 0; j < links.size(); ++j) {
if (!m_removedLinkPreviews.contains(links[j])) { const auto linkPreview = linkPreviewComponent(links[j]);
m_components.insert(i + j + 1, linkPreviewComponent(links[j])); if (!m_removedLinkPreviews.contains(links[j]) && !linkPreview.isEmpty()) {
m_components.insert(i + j + 1, linkPreview);
} }
}; };
} }

View File

@@ -15,7 +15,7 @@
#include "neochatroom.h" #include "neochatroom.h"
struct MessageComponent { struct MessageComponent {
MessageComponentType::Type type; MessageComponentType::Type type = MessageComponentType::Other;
QString content; QString content;
QVariantMap attributes; QVariantMap attributes;
@@ -23,6 +23,11 @@ struct MessageComponent {
{ {
return type == right.type && content == right.content && attributes == right.attributes; return type == right.type && content == right.content && attributes == right.attributes;
} }
bool isEmpty() const
{
return type == MessageComponentType::Other;
}
}; };
/** /**