When handling fetched shares, record shared-with-me related information in sharemodel properties

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-10-20 17:36:20 +08:00
parent a72f23a4d3
commit cf0dd27b5f
No known key found for this signature in database
GPG key ID: C839200C384636B0

View file

@ -491,10 +491,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;
}