From 236fb901a3da9962da8669493e0fc37402011cbd Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Apr 2019 21:32:22 -0600 Subject: [PATCH 1/6] Update LabsSettings controller --- .../Controllers/Settings/LabsSettings.php | 27 ++++++------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/app/Http/Controllers/Settings/LabsSettings.php b/app/Http/Controllers/Settings/LabsSettings.php index f0020b570..8d6187fda 100644 --- a/app/Http/Controllers/Settings/LabsSettings.php +++ b/app/Http/Controllers/Settings/LabsSettings.php @@ -32,7 +32,7 @@ trait LabsSettings { $profile = $request->user()->profile; $cookie = Cookie::forget('dark-mode'); - if($request->has('dark_mode') && $profile->profile_layout != 'moment') { + if($request->has('dark_mode')) { if($request->dark_mode == 'on') { $cookie = Cookie::make('dark-mode', true, 43800); } @@ -42,15 +42,10 @@ trait LabsSettings { if($profile->profile_layout != 'moment') { $profile->profile_layout = 'moment'; $changes = true; - } else { - $profile->profile_layout = null; - $changes = true; - } + } } else { - if($profile->profile_layout == 'moment') { - $profile->profile_layout = null; - $changes = true; - } + $profile->profile_layout = null; + $changes = true; } if($request->has('profile_suggestions')) { @@ -58,17 +53,11 @@ trait LabsSettings { $profile->is_suggestable = true; $changes = true; SuggestionService::set($profile->id); - } else { - $profile->is_suggestable = false; - $changes = true; - SuggestionService::del($profile->id); - } + } } else { - if($profile->is_suggestable == true) { - $profile->is_suggestable = false; - $changes = true; - SuggestionService::del($profile->id); - } + $profile->is_suggestable = false; + $changes = true; + SuggestionService::del($profile->id); } if($changes == true) { From e4e6f10c9016eb8cf86b18347ae42941391a0023 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Apr 2019 21:49:17 -0600 Subject: [PATCH 2/6] Update AccountController --- app/Http/Controllers/AccountController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 713e037cc..dc333a515 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -207,6 +207,7 @@ class AccountController extends Controller Cache::forget("user:filter:list:$pid"); Cache::forget("feature:discover:people:$pid"); Cache::forget("feature:discover:posts:$pid"); + Cache::forget("api:local:exp:rec:$pid"); return redirect()->back(); } @@ -257,6 +258,7 @@ class AccountController extends Controller Cache::forget("user:filter:list:$pid"); Cache::forget("feature:discover:people:$pid"); Cache::forget("feature:discover:posts:$pid"); + Cache::forget("api:local:exp:rec:$pid"); if($request->wantsJson()) { return response()->json([200]); @@ -310,6 +312,8 @@ class AccountController extends Controller Cache::forget("user:filter:list:$pid"); Cache::forget("feature:discover:people:$pid"); Cache::forget("feature:discover:posts:$pid"); + Cache::forget("api:local:exp:rec:$pid"); + return redirect()->back(); } @@ -360,6 +364,8 @@ class AccountController extends Controller Cache::forget("user:filter:list:$pid"); Cache::forget("feature:discover:people:$pid"); Cache::forget("feature:discover:posts:$pid"); + Cache::forget("api:local:exp:rec:$pid"); + return redirect()->back(); } From 99503ec4641721d48da99cda787258a185f3480c Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Apr 2019 22:22:03 -0600 Subject: [PATCH 3/6] Update ApiController --- app/Http/Controllers/ApiController.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index e54083d94..95bf0f6db 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -4,8 +4,10 @@ namespace App\Http\Controllers; use App\Http\Controllers\Api\BaseApiController; use App\{ + Follower, Like, - Profile + Profile, + UserFilter }; use Auth; use Cache; @@ -58,13 +60,18 @@ class ApiController extends BaseApiController $id = Auth::user()->profile->id; - $following = Cache::get('profile:following:'.$id, []); + $following = Cache::remember('profile:following:'.$id, now()->addHours(12), function() use ($id) { + return Follower::whereProfileId($id)->pluck('following_id')->toArray(); + }); + array_push($following, $id); $ids = SuggestionService::get(); + $filters = UserFilter::whereUserId($id) + ->whereFilterableType('App\Profile') + ->whereIn('filter_type', ['mute', 'block']) + ->pluck('filterable_id')->toArray(); + $following = array_merge($following, $filters); $res = Cache::remember('api:local:exp:rec:'.$id, now()->addMinutes(5), function() use($id, $following, $ids) { - - array_push($following, $id); - return Profile::select( 'id', 'username' From 0d34ffa142051da3ed1f06e37bd9a17d4c3dc8c4 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Apr 2019 22:36:28 -0600 Subject: [PATCH 4/6] Update Profile, add unfollow button to following modal --- resources/assets/js/components/Profile.vue | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/resources/assets/js/components/Profile.vue b/resources/assets/js/components/Profile.vue index 4507056f1..3dad39604 100644 --- a/resources/assets/js/components/Profile.vue +++ b/resources/assets/js/components/Profile.vue @@ -397,8 +397,16 @@ {{user.display_name}}

+
+ Unfollow +
+
+
+

You are not following anyone.

+
+

Load more

@@ -1025,6 +1033,17 @@ export default { return; } this.$refs.visitorContextMenu.show(); + }, + + followModalAction(id, index, type = 'following') { + axios.post('/i/follow', { + item: id + }).then(res => { + if(type == 'following') { + this.following.splice(index, 1); + this.profile.following_count--; + } + }) } } } From 63dc9a3c2bd5b9aaebd0af54b7a7a193d7e80bf6 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Apr 2019 22:37:04 -0600 Subject: [PATCH 5/6] Update Timeline, add unfollow button to following modal --- resources/assets/js/components/Timeline.vue | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index 2071b2795..34112e1e4 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -287,9 +287,15 @@ {{user.display_name}}

+ Unfollow -
+
+
+

You are not following anyone.

+
+
+

Load more

@@ -973,6 +979,16 @@ }).then(res => { this.suggestions.splice(index, 1); }) + }, + + followModalAction(id, index, type = 'following') { + axios.post('/i/follow', { + item: id + }).then(res => { + if(type == 'following') { + this.following.splice(index, 1); + } + }) } } } From 0f4443656e92e945ab33a4b63c94843138c2dcaf Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 28 Apr 2019 22:37:48 -0600 Subject: [PATCH 6/6] Update labs settings, allow dark mode and MomentUI --- resources/views/settings/labs.blade.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/resources/views/settings/labs.blade.php b/resources/views/settings/labs.blade.php index 270bdf364..47613a8ec 100644 --- a/resources/views/settings/labs.blade.php +++ b/resources/views/settings/labs.blade.php @@ -31,7 +31,6 @@

MomentUI offers an alternative layout for posts and your profile.

- @if($profile->profile_layout != 'moment')
hasCookie('dark-mode') ? 'checked':''}}>

Use dark mode theme.

- @endif

Discovery