Display share owner rather than file owner (this is more relevant to user)
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Sun, 20 Oct 2024 09:48:32 +0000 (17:48 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 22 Nov 2024 08:33:49 +0000 (16:33 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/filedetails/ShareView.qml
src/gui/filedetails/sharemodel.cpp
src/gui/filedetails/sharemodel.h

index 11e7b2a259c4d5f29bc2b685c4c6a6715c9ad3e0..13a3d304925542b821c6fbae8992abbbe15e7745 100644 (file)
@@ -145,15 +145,15 @@ ColumnLayout {
         Layout.rightMargin: root.horizontalPadding
 
         EnforcedPlainTextLabel {
-            visible: shareModel.displayFileOwner
-            text: qsTr("Shared with you by %1").arg(shareModel.fileOwnerDisplayName)
+            visible: shareModel.displayShareOwner
+            text: qsTr("Shared with you by %1").arg(shareModel.shareOwnerDisplayName)
         }
         EnforcedPlainTextLabel {
             visible: shareModel.sharedWithMeExpires
             text: qsTr("Expires in %1").arg(shareModel.sharedWithMeRemainingTimeString)
         }
 
-        visible: shareModel.displayFileOwner
+        visible: shareModel.displayShareOwner
     }
 
     ShareeSearchField {
index 3a26159632388cbdf6e29cb8853bf1704d417889..64c2d7aea8264aa09d2e4dd9b84172ba42059f69 100644 (file)
@@ -220,8 +220,8 @@ void ShareModel::resetData()
     _fetchOngoing = false;
     _hasInitialShareFetchCompleted = false;
     _sharees.clear();
-    _displayFileOwner = false;
-    _fileOwnerDisplayName.clear();
+    _displayShareOwner = false;
+    _shareOwnerDisplayName.clear();
     _sharedWithMeExpires = false;
     _sharedWithMeRemainingTimeString.clear();
 
@@ -229,8 +229,8 @@ void ShareModel::resetData()
     Q_EMIT fetchOngoingChanged();
     Q_EMIT hasInitialShareFetchCompletedChanged();
     Q_EMIT shareesChanged();
-    Q_EMIT displayFileOwnerChanged();
-    Q_EMIT fileOwnerDisplayNameChanged();
+    Q_EMIT displayShareOwnerChanged();
+    Q_EMIT shareOwnerDisplayNameChanged();
     Q_EMIT sharedWithMeExpiresChanged();
     Q_EMIT sharedWithMeRemainingTimeStringChanged();
 
@@ -465,12 +465,7 @@ void ShareModel::slotPropfindReceived(const QVariantMap &result)
 
     const auto privateLinkUrl = result["privatelink"].toString();
     _fileRemoteId = result["fileid"].toByteArray();
-    
-    _displayFileOwner = result["owner-id"].toString() != _accountState->account()->davUser();
-    Q_EMIT displayFileOwnerChanged();
-    _fileOwnerDisplayName = result["owner-display-name"].toString();
-    Q_EMIT fileOwnerDisplayNameChanged();
-
+     
     if (!privateLinkUrl.isEmpty()) {
         qCInfo(lcShareModel) << "Received private link url for" << _sharePath << privateLinkUrl;
         _privateLinkUrl = privateLinkUrl;
@@ -495,6 +490,11 @@ void ShareModel::slotSharesFetched(const QList<SharePtr> &shares)
         if (share.isNull()) {
             continue;
         } else if (const auto selfUserId = _accountState->account()->davUser(); share->getUidOwner() != selfUserId) {
+            _displayShareOwner = true;
+            Q_EMIT displayShareOwnerChanged();
+            _shareOwnerDisplayName = share->getOwnerDisplayName();
+            Q_EMIT shareOwnerDisplayNameChanged();
+
             if (share->getShareType() == Share::TypeUser &&
                 share->getShareWith() &&
                 share->getShareWith()->shareWith() == selfUserId)
@@ -1409,14 +1409,14 @@ bool ShareModel::isShareDisabledEncryptedFolder() const
     return _isShareDisabledEncryptedFolder;
 }
 
-bool ShareModel::displayFileOwner() const
+bool ShareModel::displayShareOwner() const
 {
-    return _displayFileOwner;
+    return _displayShareOwner;
 }
 
-QString ShareModel::fileOwnerDisplayName() const
+QString ShareModel::shareOwnerDisplayName() const
 {
-    return _fileOwnerDisplayName;
+    return _shareOwnerDisplayName;
 }
 
 QString ShareModel::sharedWithMeRemainingTimeString() const
index 3608f0e97819363ed46e04ef6e1dda4231b12755..2a419a7f342d330079c04bfc08e4ad0c7b264ca5 100644 (file)
@@ -38,8 +38,8 @@ class ShareModel : public QAbstractListModel
     Q_PROPERTY(bool hasInitialShareFetchCompleted READ hasInitialShareFetchCompleted NOTIFY hasInitialShareFetchCompletedChanged)
     Q_PROPERTY(bool serverAllowsResharing READ serverAllowsResharing NOTIFY serverAllowsResharingChanged)
     Q_PROPERTY(QVariantList sharees READ sharees NOTIFY shareesChanged)
-    Q_PROPERTY(bool displayFileOwner READ displayFileOwner NOTIFY displayFileOwnerChanged)
-    Q_PROPERTY(QString fileOwnerDisplayName READ fileOwnerDisplayName NOTIFY fileOwnerDisplayNameChanged)
+    Q_PROPERTY(bool displayShareOwner READ displayShareOwner NOTIFY displayShareOwnerChanged)
+    Q_PROPERTY(QString shareOwnerDisplayName READ shareOwnerDisplayName NOTIFY shareOwnerDisplayNameChanged)
     Q_PROPERTY(bool sharedWithMeExpires READ sharedWithMeExpires NOTIFY sharedWithMeExpiresChanged)
     Q_PROPERTY(QString sharedWithMeRemainingTimeString READ sharedWithMeRemainingTimeString NOTIFY sharedWithMeRemainingTimeStringChanged)
 
@@ -130,8 +130,8 @@ public:
 
     [[nodiscard]] QVariantList sharees() const;
 
-    [[nodiscard]] bool displayFileOwner() const;
-    [[nodiscard]] QString fileOwnerDisplayName() const;
+    [[nodiscard]] bool displayShareOwner() const;
+    [[nodiscard]] QString shareOwnerDisplayName() const;
     [[nodiscard]] bool sharedWithMeExpires() const;
     [[nodiscard]] QString sharedWithMeRemainingTimeString() const;
 
@@ -152,8 +152,8 @@ signals:
     void shareesChanged();
     void internalLinkReady();
     void serverAllowsResharingChanged();
-    void displayFileOwnerChanged();
-    void fileOwnerDisplayNameChanged();
+    void displayShareOwnerChanged();
+    void shareOwnerDisplayNameChanged();
     void sharedWithMeExpiresChanged();
     void sharedWithMeRemainingTimeStringChanged();
 
@@ -259,8 +259,8 @@ private:
     SyncJournalFileLockInfo _filelockState;
     QString _privateLinkUrl;
     QByteArray _fileRemoteId;
-    bool _displayFileOwner = false;
-    QString _fileOwnerDisplayName;
+    bool _displayShareOwner = false;
+    QString _shareOwnerDisplayName;
     bool _sharedWithMeExpires = false;
     QString _sharedWithMeRemainingTimeString;