mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-18 12:31:27 +00:00
Merge pull request #479 from pixelfed/frontend-ui-refactor
Update Discover feature
This commit is contained in:
commit
070984df3d
2 changed files with 47 additions and 21 deletions
|
@ -2,12 +2,14 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Follower;
|
use App\{
|
||||||
use App\Hashtag;
|
Follower,
|
||||||
use App\Profile;
|
Hashtag,
|
||||||
use App\Status;
|
Profile,
|
||||||
use App\UserFilter;
|
Status,
|
||||||
use Auth;
|
UserFilter
|
||||||
|
};
|
||||||
|
use Auth, DB, Cache;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
class DiscoverController extends Controller
|
class DiscoverController extends Controller
|
||||||
|
@ -21,25 +23,35 @@ class DiscoverController extends Controller
|
||||||
{
|
{
|
||||||
$pid = Auth::user()->profile->id;
|
$pid = Auth::user()->profile->id;
|
||||||
|
|
||||||
$following = Follower::whereProfileId($pid)
|
$following = Cache::remember('feature:discover:following:'.$pid, 15, function() use($pid) {
|
||||||
|
$following = Follower::whereProfileId($pid)
|
||||||
->pluck('following_id');
|
->pluck('following_id');
|
||||||
$filtered = UserFilter::whereUserId($pid)
|
$filtered = UserFilter::whereUserId($pid)
|
||||||
->whereFilterableType('App\Profile')
|
->whereFilterableType('App\Profile')
|
||||||
->whereIn('filter_type', ['mute', 'block'])
|
->whereIn('filter_type', ['mute', 'block'])
|
||||||
->pluck('filterable_id');
|
->pluck('filterable_id');
|
||||||
$following->push($pid);
|
$following->push($pid);
|
||||||
|
|
||||||
if($filtered->count() > 0) {
|
if($filtered->count() > 0) {
|
||||||
$following->push($filtered);
|
$following->push($filtered);
|
||||||
}
|
}
|
||||||
|
return $following;
|
||||||
|
});
|
||||||
|
|
||||||
$people = Profile::inRandomOrder()
|
$people = Cache::remember('feature:discover:people:'.$pid, 15, function() use($following) {
|
||||||
->whereNotIn('id', $following)
|
return Profile::inRandomOrder()
|
||||||
->whereIsPrivate(false)
|
->whereHas('statuses')
|
||||||
->take(3)
|
->whereNull('domain')
|
||||||
->get();
|
->whereNotIn('id', $following)
|
||||||
|
->whereIsPrivate(false)
|
||||||
|
->take(3)
|
||||||
|
->get();
|
||||||
|
});
|
||||||
|
|
||||||
$posts = Status::whereHas('media')
|
$posts = Status::whereHas('media')
|
||||||
|
->whereHas('profile', function($q) {
|
||||||
|
$q->where('is_private', false);
|
||||||
|
})
|
||||||
->whereVisibility('public')
|
->whereVisibility('public')
|
||||||
->where('profile_id', '!=', $pid)
|
->where('profile_id', '!=', $pid)
|
||||||
->whereNotIn('profile_id', $following)
|
->whereNotIn('profile_id', $following)
|
||||||
|
|
|
@ -25,6 +25,13 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@if($people->count() == 0)
|
||||||
|
<div class="col-12 text-center text-muted">
|
||||||
|
<h4 class="font-weight-bold">No results found</h4>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section class="pt-5 mt-5">
|
<section class="pt-5 mt-5">
|
||||||
|
@ -49,6 +56,13 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
|
@if($posts->count() == 0)
|
||||||
|
<div class="col-12 text-center text-muted">
|
||||||
|
<h4 class="font-weight-bold">No results found</h4>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue