Skip to content

Commit 5ac9d0e

Browse files
committed
Update Embeds. Fix Profile + Status embeds, remove following count and improve cache invalidation and hidden follower counts
1 parent d31a1db commit 5ac9d0e

File tree

6 files changed

+29
-11
lines changed

6 files changed

+29
-11
lines changed

app/Http/Controllers/ComposeController.php

+1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ public function store(Request $request)
427427
Cache::forget('profile:status_count:'.$profile->id);
428428
Cache::forget('status:transformer:media:attachments:'.$status->id);
429429
Cache::forget($user->storageUsedKey());
430+
Cache::forget('profile:embed:' . $status->profile_id);
430431

431432
return $status->url();
432433
}

app/Http/Controllers/Settings/PrivacySettings.php

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ public function privacyStore(Request $request)
7474
}
7575
Cache::forget('profile:settings:' . $profile->id);
7676
Cache::forget('user:account:id:' . $profile->user_id);
77+
Cache::forget('profile:follower_count:' . $profile->id);
78+
Cache::forget('profile:following_count:' . $profile->id);
79+
Cache::forget('profile:embed:' . $profile->id);
7780
return redirect(route('settings.privacy'))->with('status', 'Settings successfully updated!');
7881
}
7982

app/Profile.php

+6
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public function statuses()
6565
public function followingCount($short = false)
6666
{
6767
$count = Cache::remember('profile:following_count:'.$this->id, now()->addMonths(1), function() {
68+
if($this->domain == null && $this->user->settings->show_profile_following_count == false) {
69+
return 0;
70+
}
6871
$count = $this->following()->count();
6972
if($this->following_count != $count) {
7073
$this->following_count = $count;
@@ -79,6 +82,9 @@ public function followingCount($short = false)
7982
public function followerCount($short = false)
8083
{
8184
$count = Cache::remember('profile:follower_count:'.$this->id, now()->addMonths(1), function() {
85+
if($this->domain == null && $this->user->settings->show_profile_follower_count == false) {
86+
return 0;
87+
}
8288
$count = $this->followers()->count();
8389
if($this->followers_count != $count) {
8490
$this->followers_count = $count;

resources/views/profile/embed-removed.blade.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
<link rel="apple-touch-icon" type="image/png" href="/img/favicon.png?v=2">
1919
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
2020
<style type="text/css">
21-
body.embed-card {
21+
.embed-card {
22+
display: flex;
23+
align-items: center;
24+
justify-content: center;
25+
width: 100vw;
26+
height: 100vh;
27+
min-height: 573px;
2228
background: #fff !important;
2329
margin: 0;
2430
padding-bottom: 0;
@@ -31,8 +37,8 @@
3137
</style>
3238
</head>
3339
<body class="bg-white">
34-
<div class="embed-card">
35-
<div class="card status-card-embed card-md-rounded-0 border card-body border shadow-none rounded-0 d-flex justify-content-center align-items-center">
40+
<div class="embed-card border">
41+
<div class="card status-card-embed card-md-rounded-0 card-body shadow-none rounded-0">
3642
<div class="text-center p-5">
3743
<img src="/img/pixelfed-icon-color.svg" width="40px" height="40px">
3844
<p class="h2 py-3 font-weight-bold">Pixelfed</p>

resources/views/profile/embed.blade.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,9 @@
5454
<p class="mb-0 text-muted text-uppercase small font-weight-bold">Posts</p>
5555
</div>
5656
<div class="text-center">
57-
<p class="mb-0 font-weight-bold prettyCount">{{$profile->followers()->count()}}</p>
57+
<p class="mb-0 font-weight-bold prettyCount">{{$profile->followerCount(true)}}</p>
5858
<p class="mb-0 text-muted text-uppercase small font-weight-bold">Followers</p>
5959
</div>
60-
<div class="text-center">
61-
<p class="mb-0 font-weight-bold prettyCount">{{$profile->following()->count()}}</p>
62-
<p class="mb-0 text-muted text-uppercase small font-weight-bold">Following</p>
63-
</div>
6460
<div class="text-center">
6561
<p class="mb-0"><a href="/i/intent/follow?user={{$profile->username}}" class="btn btn-primary btn-sm py-1 px-4 text-uppercase font-weight-bold" target="_blank">Follow</a></p>
6662
</div>

resources/views/status/embed-removed.blade.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
<link rel="apple-touch-icon" type="image/png" href="/img/favicon.png?v=2">
1919
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
2020
<style type="text/css">
21-
body.embed-card {
21+
.embed-card {
22+
display: flex;
23+
align-items: center;
24+
justify-content: center;
25+
width: 100vw;
26+
height: 100vh;
27+
min-height: 573px;
2228
background: #fff !important;
2329
margin: 0;
2430
padding-bottom: 0;
@@ -31,8 +37,8 @@
3137
</style>
3238
</head>
3339
<body class="bg-white">
34-
<div class="embed-card">
35-
<div class="card status-card-embed card-md-rounded-0 border card-body border shadow-none rounded-0 d-flex justify-content-center align-items-center">
40+
<div class="embed-card border">
41+
<div class="card status-card-embed card-md-rounded-0 card-body shadow-none rounded-0">
3642
<div class="text-center p-5">
3743
<img src="/img/pixelfed-icon-color.svg" width="40px" height="40px">
3844
<p class="h2 py-3 font-weight-bold">Pixelfed</p>

0 commit comments

Comments
 (0)