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