When handling fetched shares, record shared-with-me related information in sharemodel...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Sun, 20 Oct 2024 09:36:20 +0000 (17:36 +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/sharemodel.cpp

index c8257e8df71e5e80991afa15e0aa535162043e60..3a26159632388cbdf6e29cb8853bf1704d417889 100644 (file)
@@ -492,10 +492,25 @@ void ShareModel::slotSharesFetched(const QList<SharePtr> &shares)
     qCInfo(lcSharing) << "Fetched" << shares.count() << "shares";
 
     for (const auto &share : shares) {
-        if (share.isNull() ||
-            share->account().isNull() ||
-            share->getUidOwner() != share->account()->davUser()) {
-
+        if (share.isNull()) {
+            continue;
+        } else if (const auto selfUserId = _accountState->account()->davUser(); share->getUidOwner() != selfUserId) {
+            if (share->getShareType() == Share::TypeUser &&
+                share->getShareWith() &&
+                share->getShareWith()->shareWith() == selfUserId)
+            {
+                const auto userShare = share.objectCast<UserGroupShare>();
+                const auto expireDate = userShare->getExpireDate();
+                const auto daysToExpire = QDate::currentDate().daysTo(expireDate);
+                _sharedWithMeExpires = expireDate.isValid();
+                Q_EMIT sharedWithMeExpiresChanged();
+                _sharedWithMeRemainingTimeString = daysToExpire > 1
+                    ? tr("%1 days").arg(daysToExpire)
+                    :  daysToExpire > 0
+                        ? tr("1 day")
+                        : tr("Today");
+                Q_EMIT sharedWithMeRemainingTimeStringChanged();
+            }
             continue;
         }