@@ -363,6 +363,7 @@ void ShareModel::initShareManager()
363
363
if (_manager.isNull () && sharingPossible) {
364
364
_manager.reset (new ShareManager (_accountState->account (), this ));
365
365
connect (_manager.data (), &ShareManager::sharesFetched, this , &ShareModel::slotSharesFetched);
366
+ connect (_manager.data (), &ShareManager::sharedWithMeFetched, this , &ShareModel::slotSharedWithMeFetched);
366
367
connect (_manager.data (), &ShareManager::shareCreated, this , [&] {
367
368
_manager->fetchShares (_sharePath);
368
369
});
@@ -375,6 +376,7 @@ void ShareModel::initShareManager()
375
376
});
376
377
377
378
_manager->fetchShares (_sharePath);
379
+ _manager->fetchSharedWithMe (_sharePath);
378
380
}
379
381
}
380
382
@@ -489,38 +491,13 @@ void ShareModel::slotSharesFetched(const QList<SharePtr> &shares)
489
491
qCInfo (lcSharing) << " Fetched" << shares.count () << " shares" ;
490
492
491
493
for (const auto &share : shares) {
492
- if (share.isNull ()) {
494
+ if (share.isNull () ||
495
+ share->account ().isNull () ||
496
+ share->getUidOwner () != share->account ()->davUser ()) {
493
497
continue ;
494
- } else if (const auto selfUserId = share->account ()->davUser (); share->getUidOwner () != selfUserId) {
495
- _displayShareOwner = true ;
496
- Q_EMIT displayShareOwnerChanged ();
497
- _shareOwnerDisplayName = share->getOwnerDisplayName ();
498
- Q_EMIT shareOwnerDisplayNameChanged ();
499
- _shareOwnerAvatar = " image://avatars/user-id="
500
- + share->getUidOwner ()
501
- + " /local-account:"
502
- + share->account ()->displayName ();
503
- Q_EMIT shareOwnerAvatarChanged ();
504
-
505
- if (share->getShareType () == Share::TypeUser &&
506
- share->getShareWith () &&
507
- share->getShareWith ()->shareWith () == selfUserId)
508
- {
509
- const auto userShare = share.objectCast <UserGroupShare>();
510
- const auto expireDate = userShare->getExpireDate ();
511
- const auto daysToExpire = QDate::currentDate ().daysTo (expireDate);
512
- _sharedWithMeExpires = expireDate.isValid ();
513
- Q_EMIT sharedWithMeExpiresChanged ();
514
- _sharedWithMeRemainingTimeString = daysToExpire > 1
515
- ? tr (" %1 days" ).arg (daysToExpire)
516
- : daysToExpire > 0
517
- ? tr (" 1 day" )
518
- : tr (" Today" );
519
- Q_EMIT sharedWithMeRemainingTimeStringChanged ();
520
- }
521
- } else {
522
- slotAddShare (share);
523
498
}
499
+
500
+ slotAddShare (share);
524
501
}
525
502
526
503
// Perform forward pass on shares and check for duplicate display names; store these indeces so
@@ -561,6 +538,47 @@ void ShareModel::slotSharesFetched(const QList<SharePtr> &shares)
561
538
handleLinkShare ();
562
539
}
563
540
541
+ void ShareModel::slotSharedWithMeFetched (const QList<OCC::SharePtr> &shares)
542
+ {
543
+ qCInfo (lcSharing) << " Fetched" << shares.count () << " shares that have been shared_with_me" ;
544
+
545
+ for (const auto &share : shares) {
546
+ if (share.isNull ()) {
547
+ continue ;
548
+ }
549
+
550
+ const auto selfUserId = share->account ()->davUser ();
551
+ if (share->getUidOwner () == selfUserId) {
552
+ continue ;
553
+ }
554
+
555
+ _displayShareOwner = true ;
556
+ Q_EMIT displayShareOwnerChanged ();
557
+ _shareOwnerDisplayName = share->getOwnerDisplayName ();
558
+ Q_EMIT shareOwnerDisplayNameChanged ();
559
+ _shareOwnerAvatar = QStringLiteral (" image://avatars/user-id=%1/local-account:%2" )
560
+ .arg (share->getUidOwner (), share->account ()->displayName ());
561
+ Q_EMIT shareOwnerAvatarChanged ();
562
+
563
+ if (share->getShareType () == Share::TypeUser &&
564
+ share->getShareWith () &&
565
+ share->getShareWith ()->shareWith () == selfUserId)
566
+ {
567
+ const auto userShare = share.objectCast <UserGroupShare>();
568
+ const auto expireDate = userShare->getExpireDate ();
569
+ const auto daysToExpire = QDate::currentDate ().daysTo (expireDate);
570
+ _sharedWithMeExpires = expireDate.isValid ();
571
+ Q_EMIT sharedWithMeExpiresChanged ();
572
+ _sharedWithMeRemainingTimeString = daysToExpire > 1
573
+ ? tr (" %1 days" ).arg (daysToExpire)
574
+ : daysToExpire == 1
575
+ ? tr (" 1 day" )
576
+ : tr (" Today" );
577
+ Q_EMIT sharedWithMeRemainingTimeStringChanged ();
578
+ }
579
+ }
580
+ }
581
+
564
582
void ShareModel::setupInternalLinkShare ()
565
583
{
566
584
if (!_accountState ||
0 commit comments