Improve the handling of switching link preivews on and off.

First make sure that the global setting is tied into the room setting, previously it was a bit of a patchwork that worked more by luck than judgement. The two levels of global and room level are properly tied together in a hierarchy.

Add a message in the room when global notifcations re turned off. This has caused confusion in the past when people don't realise there are 2 levels.
This commit is contained in:
James Graham
2025-02-27 16:37:33 +00:00
parent 77cedef5bb
commit 4af4bfd55f
7 changed files with 57 additions and 6 deletions

View File

@@ -145,6 +145,10 @@ void NeoChatConnection::connectSignals()
connect(NeoChatConfig::self(), &NeoChatConfig::PreferUsingEncryptionChanged, this, [] {
setDirectChatEncryptionDefault(NeoChatConfig::preferUsingEncryption());
});
setGlobalUrlPreviewEnabled(NeoChatConfig::showLinkPreview());
connect(NeoChatConfig::self(), &NeoChatConfig::ShowLinkPreviewChanged, this, [this]() {
setGlobalUrlPreviewEnabled(NeoChatConfig::showLinkPreview());
});
}
int NeoChatConnection::badgeNotificationCount() const
@@ -167,6 +171,25 @@ void NeoChatConnection::refreshBadgeNotificationCount()
}
}
bool NeoChatConnection::globalUrlPreviewEnabled()
{
return m_globalUrlPreviewEnabled;
}
void NeoChatConnection::setGlobalUrlPreviewEnabled(bool newState)
{
if (m_globalUrlPreviewEnabled == newState) {
return;
}
m_globalUrlPreviewEnabled = newState;
if (!m_globalUrlPreviewEnabled) {
m_linkPreviewers.clear();
}
NeoChatConfig::setShowLinkPreview(m_globalUrlPreviewEnabled);
Q_EMIT globalUrlPreviewEnabledChanged();
}
void NeoChatConnection::logout(bool serverSideLogout)
{
SettingsGroup(u"Accounts"_s).remove(userId());
@@ -505,7 +528,7 @@ QString NeoChatConnection::accountDataJsonString(const QString &type) const
LinkPreviewer *NeoChatConnection::previewerForLink(const QUrl &link)
{
if (!NeoChatConfig::showLinkPreview()) {
if (!m_globalUrlPreviewEnabled) {
return nullptr;
}