Compare commits

...

1 Commits

Author SHA1 Message Date
Azhar Momin
7e3e0b9b96 Allow disabling sending public read receipts 2026-02-23 14:12:46 +05:30
10 changed files with 46 additions and 19 deletions

View File

@@ -49,6 +49,9 @@
<entry name="TypingNotifications" type="bool">
<default>true</default>
</entry>
<entry name="PublicReadReceipts" type="bool">
<default>true</default>
</entry>
<entry name="AutoRoomInfoDrawer" type="bool">
<label>Automatic Hide/Unhide Room Information</label>
<default>true</default>
@@ -227,4 +230,3 @@
</entry>
</group>
</kcfg>

View File

@@ -1935,13 +1935,23 @@ bool NeoChatRoom::spaceHasUnreadMessages() const
return SpaceHierarchyCache::instance().spaceHasUnreadMessages(id());
}
void NeoChatRoom::markAllChildrenMessagesAsRead()
void NeoChatRoom::markAllChildrenMessagesAsRead(bool sendPublicReceipts)
{
if (isSpace()) {
SpaceHierarchyCache::instance().markAllChildrenMessagesAsRead(id());
SpaceHierarchyCache::instance().markAllChildrenMessagesAsRead(id(), sendPublicReceipts);
}
}
void NeoChatRoom::markAllMessagesAsRead(bool sendPublicReceipts)
{
#if Quotient_VERSION_MINOR >= 10
Room::markAllMessagesAsRead(sendPublicReceipts);
#else
Q_UNUSED(sendPublicReceipts)
Room::markAllMessagesAsRead();
#endif
}
QList<QString> NeoChatRoom::sortedMemberIds() const
{
return m_sortedMemberIds;

View File

@@ -679,7 +679,12 @@ public:
/**
* @brief Mark the space and all its children messages as read.
*/
Q_INVOKABLE void markAllChildrenMessagesAsRead();
Q_INVOKABLE void markAllChildrenMessagesAsRead(bool sendPublicReceipts);
/**
* @brief Mark all messages in the room as read up to the latest event.
*/
Q_INVOKABLE void markAllMessagesAsRead(bool sendPublicReceipts = true);
/**
* @return List of members in this room, sorted by power level and then by name.

View File

@@ -254,7 +254,7 @@ void SpaceHierarchyCache::setRecommendedSpaceHidden(bool hidden)
Q_EMIT recommendedSpaceHiddenChanged();
}
void SpaceHierarchyCache::markAllChildrenMessagesAsRead(const QString &spaceId)
void SpaceHierarchyCache::markAllChildrenMessagesAsRead(const QString &spaceId, bool sendPublicReceipts)
{
const auto children = m_spaceHierarchy[spaceId];
@@ -277,14 +277,14 @@ void SpaceHierarchyCache::markAllChildrenMessagesAsRead(const QString &spaceId)
child,
&NeoChatRoom::addedMessages,
child,
[child] {
[child, sendPublicReceipts] {
if (child->messageEvents().crbegin() != child->historyEdge()) {
child->markAllMessagesAsRead();
child->markAllMessagesAsRead(sendPublicReceipts);
}
},
Qt::SingleShotConnection);
} else {
child->markAllMessagesAsRead();
child->markAllMessagesAsRead(sendPublicReceipts);
}
}
}

View File

@@ -100,7 +100,7 @@ public:
bool recommendedSpaceHidden() const;
void setRecommendedSpaceHidden(bool hidden);
void markAllChildrenMessagesAsRead(const QString &spaceId);
void markAllChildrenMessagesAsRead(const QString &spaceId, bool sendPublicReceipts);
Q_SIGNALS:
void spaceHierarchyChanged();

View File

@@ -47,7 +47,7 @@ KirigamiComponents.ConvergentContextMenu {
text: i18nc("@action:inmenu", "Mark as Read")
icon.name: "checkmark"
enabled: root.room.notificationCount > 0 || root.room.highlightCount > 0
onTriggered: root.room.markAllMessagesAsRead()
onTriggered: root.room.markAllMessagesAsRead(NeoChatConfig.publicReadReceipts)
}
Kirigami.Action {

View File

@@ -45,7 +45,7 @@ KirigamiComponents.ConvergentContextMenu {
icon.name: "checkmark"
enabled: root.room.spaceHasUnreadMessages
onTriggered: {
root.room.markAllChildrenMessagesAsRead();
root.room.markAllChildrenMessagesAsRead(NeoChatConfig.publicReadReceipts);
}
}

View File

@@ -67,8 +67,18 @@ FormCard.FormCardPage {
NeoChatConfig.save();
}
}
FormCard.FormCheckDelegate {
id: publicReceiptsDelegate
text: i18nc("@option:check", "Send read receipts")
checked: NeoChatConfig.publicReadReceipts
enabled: !NeoChatConfig.isPublicReadReceiptsImmutable
onToggled: {
NeoChatConfig.publicReadReceipts = checked;
NeoChatConfig.save();
}
}
FormCard.FormDelegateSeparator {
above: typingNotificationsDelegate
above: publicReceiptsDelegate
below: hideImagesDelegate
}
FormCard.FormCheckDelegate {

View File

@@ -73,7 +73,7 @@ TimelineDelegate {
text: i18nc("@action:button Mark all messages up to now as read", "Mark as Read")
icon.name: "checkmark"
onClicked: root.room.markAllMessagesAsRead()
onClicked: root.room.markAllMessagesAsRead(NeoChatConfig.publicReadReceipts)
Layout.alignment: Qt.AlignRight
}

View File

@@ -170,26 +170,26 @@ QQC2.ScrollView {
function onReadMarkerAdded() {
if (root.markReadCondition == LibNeoChat.TimelineMarkReadCondition.EntryVisible && messageListView.allUnreadVisible()) {
_private.room.markAllMessagesAsRead();
_private.room.markAllMessagesAsRead(NeoChatConfig.publicReadReceipts);
}
}
function onNewLocalUserEventAdded() {
messageListView.positionViewAtBeginning();
_private.room.markAllMessagesAsRead();
_private.room.markAllMessagesAsRead(NeoChatConfig.publicReadReceipts);
}
function onRoomAboutToChange(oldRoom, newRoom) {
if (root.markReadCondition == LibNeoChat.TimelineMarkReadCondition.Exit ||
(root.markReadCondition == LibNeoChat.TimelineMarkReadCondition.ExitVisible && messageListView.allUnreadVisible())
) {
oldRoom.markAllMessagesAsRead();
oldRoom.markAllMessagesAsRead(NeoChatConfig.publicReadReceipts);
}
}
function onRoomChanged(oldRoom, newRoom) {
if (root.markReadCondition == LibNeoChat.TimelineMarkReadCondition.Entry) {
newRoom.markAllMessagesAsRead();
newRoom.markAllMessagesAsRead(NeoChatConfig.publicReadReceipts);
}
}
}
@@ -202,7 +202,7 @@ QQC2.ScrollView {
if (closeToYEnd && _private.hasScrolledUpBefore) {
if (QQC2.ApplicationWindow.window && (QQC2.ApplicationWindow.window.visibility !== QQC2.ApplicationWindow.Hidden)) {
_private.room.markAllMessagesAsRead();
_private.room.markAllMessagesAsRead(NeoChatConfig.publicReadReceipts);
}
_private.hasScrolledUpBefore = false;
} else if (!closeToYEnd) {
@@ -298,7 +298,7 @@ QQC2.ScrollView {
onClicked: {
messageListView.positionViewAtBeginning();
_private.room.markAllMessagesAsRead();
_private.room.markAllMessagesAsRead(NeoChatConfig.publicReadReceipts);
}
icon.name: "go-down"