Display share owner rather than file owner (this is more relevant to user)

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-10-20 17:48:32 +08:00
parent 6620bf2dd2
commit b325686ddc
3 changed files with 25 additions and 25 deletions

View 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 {

View 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();
@ -466,11 +466,6 @@ 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

View 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;