mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-04-21 21:52:03 +02:00
previewEngine: fix display hyperlink preference
Change-Id: I3c9813e41f6c857d096d9d685d5902d3c4c361cd
This commit is contained in:
parent
eacdd8af61
commit
5ddfab1b7b
7 changed files with 11 additions and 10 deletions
|
@ -44,11 +44,12 @@ function getPreviewInfo(messageId, url) {
|
|||
})
|
||||
}
|
||||
|
||||
function parseMessage(messageId, message) {
|
||||
function parseMessage(messageId, message, showPreview) {
|
||||
var links = linkify.find(message)
|
||||
if (links.length === 0) {
|
||||
return
|
||||
}
|
||||
getPreviewInfo(messageId, links[0].href)
|
||||
if (showPreview)
|
||||
getPreviewInfo(messageId, links[0].href)
|
||||
window.jsbridge.linkifyReady(messageId, linkifyStr(message))
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import QtGraphicalEffects 1.15
|
|||
import net.jami.Models 1.1
|
||||
import net.jami.Adapters 1.1
|
||||
import net.jami.Constants 1.1
|
||||
import net.jami.Enums 1.1
|
||||
|
||||
SBSMessageBase {
|
||||
id : root
|
||||
|
@ -170,7 +171,7 @@ SBSMessageBase {
|
|||
Behavior on opacity { NumberAnimation { duration: 100 } }
|
||||
Component.onCompleted: {
|
||||
if (!Linkified) {
|
||||
MessagesAdapter.parseMessageUrls(Id, Body)
|
||||
MessagesAdapter.parseMessageUrls(Id, Body, UtilsAdapter.getAppValue(Settings.DisplayHyperlinkPreviews))
|
||||
}
|
||||
opacity = 1
|
||||
}
|
||||
|
|
|
@ -407,9 +407,9 @@ MessagesAdapter::onConversationMessagesLoaded(uint32_t, const QString& convId)
|
|||
}
|
||||
|
||||
void
|
||||
MessagesAdapter::parseMessageUrls(const QString& messageId, const QString& msg)
|
||||
MessagesAdapter::parseMessageUrls(const QString& messageId, const QString& msg, bool showPreview)
|
||||
{
|
||||
previewEngine_->parseMessage(messageId, msg);
|
||||
previewEngine_->parseMessage(messageId, msg, showPreview);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -105,7 +105,7 @@ protected:
|
|||
Q_INVOKABLE QVariantMap getMediaInfo(const QString& msg);
|
||||
Q_INVOKABLE bool isRemoteImage(const QString& msg);
|
||||
Q_INVOKABLE QString getFormattedTime(const quint64 timestamp);
|
||||
Q_INVOKABLE void parseMessageUrls(const QString& messageId, const QString& msg);
|
||||
Q_INVOKABLE void parseMessageUrls(const QString& messageId, const QString& msg, bool showPreview);
|
||||
Q_INVOKABLE void onPaste();
|
||||
Q_INVOKABLE QString getStatusString(int status);
|
||||
Q_INVOKABLE QVariantMap getTransferStats(const QString& messageId, int);
|
||||
|
|
|
@ -70,9 +70,9 @@ PreviewEngine::PreviewEngine(QObject* parent)
|
|||
}
|
||||
|
||||
void
|
||||
PreviewEngine::parseMessage(const QString& messageId, const QString& msg)
|
||||
PreviewEngine::parseMessage(const QString& messageId, const QString& msg, bool showPreview)
|
||||
{
|
||||
page()->runJavaScript(QString("parseMessage(`%1`, `%2`)").arg(messageId, msg));
|
||||
page()->runJavaScript(QString("parseMessage(`%1`, `%2`, %3)").arg(messageId, msg, showPreview ? "true" : "false"));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -52,7 +52,7 @@ public:
|
|||
explicit PreviewEngine(QObject* parent = nullptr);
|
||||
~PreviewEngine() = default;
|
||||
|
||||
void parseMessage(const QString& messageId, const QString& msg);
|
||||
void parseMessage(const QString& messageId, const QString& msg, bool showPreview);
|
||||
|
||||
Q_SIGNALS:
|
||||
void infoReady(const QString& messageId, const QVariantMap& info);
|
||||
|
|
|
@ -75,7 +75,6 @@ ColumnLayout {
|
|||
|
||||
onSwitchToggled: {
|
||||
UtilsAdapter.setAppValue(Settings.Key.DisplayHyperlinkPreviews, checked)
|
||||
MessagesAdapter.setDisplayLinks()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue