Bläddra i källkod

Update Embeds. Fix Profile + Status embeds, remove following count and improve cache invalidation and hidden follower counts

Daniel Supernault 4 år sedan
förälder
incheckning
5ac9d0e8f2

+ 1 - 0
app/Http/Controllers/ComposeController.php

@@ -427,6 +427,7 @@ class ComposeController extends Controller
 		Cache::forget('profile:status_count:'.$profile->id);
 		Cache::forget('status:transformer:media:attachments:'.$status->id);
 		Cache::forget($user->storageUsedKey());
+		Cache::forget('profile:embed:' . $status->profile_id);
 
 		return $status->url();
 	}

+ 3 - 0
app/Http/Controllers/Settings/PrivacySettings.php

@@ -74,6 +74,9 @@ trait PrivacySettings
         }
         Cache::forget('profile:settings:' . $profile->id);
         Cache::forget('user:account:id:' . $profile->user_id);
+        Cache::forget('profile:follower_count:' . $profile->id);
+        Cache::forget('profile:following_count:' . $profile->id);
+        Cache::forget('profile:embed:' . $profile->id);
         return redirect(route('settings.privacy'))->with('status', 'Settings successfully updated!');
     }
 

+ 6 - 0
app/Profile.php

@@ -65,6 +65,9 @@ class Profile extends Model
     public function followingCount($short = false)
     {
         $count = Cache::remember('profile:following_count:'.$this->id, now()->addMonths(1), function() {
+            if($this->domain == null && $this->user->settings->show_profile_following_count == false) {
+                return 0;
+            }
             $count = $this->following()->count();
             if($this->following_count != $count) {
                 $this->following_count = $count;
@@ -79,6 +82,9 @@ class Profile extends Model
     public function followerCount($short = false)
     {
         $count = Cache::remember('profile:follower_count:'.$this->id, now()->addMonths(1), function() {
+            if($this->domain == null && $this->user->settings->show_profile_follower_count == false) {
+                return 0;
+            }
             $count = $this->followers()->count();
             if($this->followers_count != $count) {
                 $this->followers_count = $count;

+ 9 - 3
resources/views/profile/embed-removed.blade.php

@@ -18,7 +18,13 @@
 	<link rel="apple-touch-icon" type="image/png" href="/img/favicon.png?v=2">
 	<link href="{{ mix('css/app.css') }}" rel="stylesheet">
 	<style type="text/css">
-		body.embed-card {
+		.embed-card {
+			display: flex;
+			align-items: center;
+			justify-content: center;
+			width: 100vw;
+			height: 100vh;
+			min-height: 573px;
 			background: #fff !important;
 			margin: 0;
 			padding-bottom: 0;
@@ -31,8 +37,8 @@
 	</style>
 </head>
 <body class="bg-white">
-	<div class="embed-card">
-		<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">
+	<div class="embed-card border">
+		<div class="card status-card-embed card-md-rounded-0 card-body shadow-none rounded-0">
 			<div class="text-center p-5">
 				<img src="/img/pixelfed-icon-color.svg" width="40px" height="40px">
 				<p class="h2 py-3 font-weight-bold">Pixelfed</p>

+ 1 - 5
resources/views/profile/embed.blade.php

@@ -54,13 +54,9 @@
           <p class="mb-0 text-muted text-uppercase small font-weight-bold">Posts</p>
         </div>
         <div class="text-center">
-          <p class="mb-0 font-weight-bold prettyCount">{{$profile->followers()->count()}}</p>
+          <p class="mb-0 font-weight-bold prettyCount">{{$profile->followerCount(true)}}</p>
           <p class="mb-0 text-muted text-uppercase small font-weight-bold">Followers</p>
         </div>
-        <div class="text-center">
-          <p class="mb-0 font-weight-bold prettyCount">{{$profile->following()->count()}}</p>
-          <p class="mb-0 text-muted text-uppercase small font-weight-bold">Following</p>
-        </div>
         <div class="text-center">
           <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>
         </div>

+ 9 - 3
resources/views/status/embed-removed.blade.php

@@ -18,7 +18,13 @@
 	<link rel="apple-touch-icon" type="image/png" href="/img/favicon.png?v=2">
 	<link href="{{ mix('css/app.css') }}" rel="stylesheet">
 	<style type="text/css">
-		body.embed-card {
+		.embed-card {
+			display: flex;
+			align-items: center;
+			justify-content: center;
+			width: 100vw;
+			height: 100vh;
+			min-height: 573px;
 			background: #fff !important;
 			margin: 0;
 			padding-bottom: 0;
@@ -31,8 +37,8 @@
 	</style>
 </head>
 <body class="bg-white">
-	<div class="embed-card">
-		<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">
+	<div class="embed-card border">
+		<div class="card status-card-embed card-md-rounded-0 card-body shadow-none rounded-0">
 			<div class="text-center p-5">
 				<img src="/img/pixelfed-icon-color.svg" width="40px" height="40px">
 				<p class="h2 py-3 font-weight-bold">Pixelfed</p>