[PATCH] Add mute/block management on the safety page
authorJoshua Goins <josh@redstrate.com>
Mon, 30 Jun 2025 20:19:34 +0000 (16:19 -0400)
committerAurélien COUDERC <coucouf@debian.org>
Thu, 24 Jul 2025 16:34:20 +0000 (18:34 +0200)
This allows you to manage your muted/blocked users without having to
navigate to their profile first.

CCBUG: 506374

Gbp-Pq: Name upstream_4f09a6e8_Add-mute-block-management-on-the-safety-page.patch

src/account/socialgraphmodel.cpp
src/account/socialgraphmodel.h
src/content/ui/SocialGraphPage.qml

index 47db3cf2f1dfbedc5e0568b6a5251c0f2c83fdf5..a49f10b0db57359e58fc010acb8bf71746004b71 100644 (file)
@@ -251,6 +251,16 @@ bool SocialGraphModel::isList() const
     return m_followListName == QStringLiteral("list");
 }
 
+bool SocialGraphModel::isBlockList() const
+{
+    return m_followListName == QStringLiteral("blocks");
+}
+
+bool SocialGraphModel::isMuteList() const
+{
+    return m_followListName == QStringLiteral("mutes");
+}
+
 void SocialGraphModel::actionAllow(const QModelIndex &index)
 {
     auto account = AccountManager::instance().selectedAccount();
@@ -371,6 +381,36 @@ void SocialGraphModel::actionAddToList(const QString &accountId)
     });
 }
 
+void SocialGraphModel::actionUnblock(const QModelIndex &index)
+{
+    auto account = AccountManager::instance().selectedAccount();
+
+    if (!checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid))
+        return;
+
+    auto requestIdentity = m_accounts[index.row()].get();
+    account->unblockAccount(requestIdentity);
+
+    beginRemoveRows({}, index.row(), index.row());
+    m_accounts.removeAt(index.row());
+    endRemoveRows();
+}
+
+void SocialGraphModel::actionUnmute(const QModelIndex &index)
+{
+    auto account = AccountManager::instance().selectedAccount();
+
+    if (!checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid))
+        return;
+
+    auto requestIdentity = m_accounts[index.row()].get();
+    account->unmuteAccount(requestIdentity);
+
+    beginRemoveRows({}, index.row(), index.row());
+    m_accounts.removeAt(index.row());
+    endRemoveRows();
+}
+
 bool SocialGraphModel::canFetchMore(const QModelIndex &parent) const
 {
     Q_UNUSED(parent);
index 4bf6fceb70115134deb27d4da579970b7f803155..918041923189f14ab304c9df70df34c1ef7bd09a 100644 (file)
@@ -23,6 +23,8 @@ class SocialGraphModel : public QAbstractListModel
     Q_PROPERTY(bool isFollowing READ isFollowing CONSTANT)
     Q_PROPERTY(bool isFollower READ isFollower CONSTANT)
     Q_PROPERTY(bool isList READ isList CONSTANT)
+    Q_PROPERTY(bool isMuteList READ isMuteList CONSTANT)
+    Q_PROPERTY(bool isBlockList READ isBlockList CONSTANT)
 
     /**
      * @brief The account id of the account we want to display
@@ -56,6 +58,8 @@ public:
     [[nodiscard]] bool isFollowing() const;
     [[nodiscard]] bool isFollower() const;
     [[nodiscard]] bool isList() const;
+    [[nodiscard]] bool isMuteList() const;
+    [[nodiscard]] bool isBlockList() const;
     [[nodiscard]] QString statusId() const;
     void setStatusId(const QString &statusId);
     [[nodiscard]] int count() const;
@@ -70,6 +74,8 @@ public Q_SLOTS:
     void actionRemoveFollower(const QModelIndex &index);
     void actionRemoveFromList(const QModelIndex &index);
     void actionAddToList(const QString &accountId);
+    void actionUnblock(const QModelIndex &index);
+    void actionUnmute(const QModelIndex &index);
 
 Q_SIGNALS:
     void loadingChanged();
index 2bc6db9b4a728bd37dcad86f2087a8755a233e7b..9133cb3058873f3b97a6d75a015fcdfc03c1c542 100644 (file)
@@ -94,6 +94,18 @@ Kirigami.ScrollablePage {
                         onClicked: model.actionRemoveFromList(model.index(delegate.index, 0))
                         visible: model.isList && model.accountId === AccountManager.selectedAccount.identity.id
                     }
+
+                    QQC2.Button {
+                        text: i18nc("@action:button Unblock this user", "Unblock")
+                        onClicked: model.actionUnblock(model.index(delegate.index, 0))
+                        visible: model.isBlockList
+                    }
+
+                    QQC2.Button {
+                        text: i18nc("@action:button Unmute this user", "Unmute")
+                        onClicked: model.actionUnmute(model.index(delegate.index, 0))
+                        visible: model.isMuteList
+                    }
                 }
 
                 QQC2.ProgressBar {