diff --git a/app/Hashtag.php b/app/Hashtag.php index 29c4ca9b2..1e3ced6ff 100644 --- a/app/Hashtag.php +++ b/app/Hashtag.php @@ -20,8 +20,8 @@ class Hashtag extends Model ); } - public function url() + public function url($suffix = '') { - return config('routes.hashtag.base').$this->slug; + return config('routes.hashtag.base').$this->slug.$suffix; } } diff --git a/app/Http/Controllers/Settings/RelationshipSettings.php b/app/Http/Controllers/Settings/RelationshipSettings.php index efc369fe6..a2f1cfea1 100644 --- a/app/Http/Controllers/Settings/RelationshipSettings.php +++ b/app/Http/Controllers/Settings/RelationshipSettings.php @@ -18,15 +18,29 @@ trait RelationshipSettings public function relationshipsHome(Request $request) { - $mode = $request->input('mode') == 'following' ? 'following' : 'followers'; + $this->validate($request, [ + 'mode' => 'nullable|string|in:following,followers,hashtags' + ]); + + $mode = $request->input('mode'); $profile = Auth::user()->profile; - $following = $followers = []; + switch ($mode) { + case 'following': + $data = $profile->following()->simplePaginate(10); + break; - if($mode == 'following') { - $data = $profile->following()->simplePaginate(10); - } else { - $data = $profile->followers()->simplePaginate(10); + case 'followers': + $data = $profile->followers()->simplePaginate(10); + break; + + case 'hashtags': + $data = $profile->hashtagFollowing()->with('hashtag')->simplePaginate(10); + break; + + default: + $data = []; + break; } return view('settings.relationships.home', compact('profile', 'mode', 'data')); diff --git a/app/Profile.php b/app/Profile.php index aec219cc6..0737f9974 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -278,4 +278,9 @@ class Profile extends Model 'hashtag_id' ); } + + public function hashtagFollowing() + { + return $this->hasMany(HashtagFollow::class); + } } diff --git a/resources/views/settings/partial/sidebar.blade.php b/resources/views/settings/partial/sidebar.blade.php index 32f4ff6cd..5606a2b74 100644 --- a/resources/views/settings/partial/sidebar.blade.php +++ b/resources/views/settings/partial/sidebar.blade.php @@ -9,9 +9,6 @@ - @if(config('pixelfed.user_invites.enabled')) + diff --git a/resources/views/settings/relationships/home.blade.php b/resources/views/settings/relationships/home.blade.php index 66b27628f..cf2a31a09 100644 --- a/resources/views/settings/relationships/home.blade.php +++ b/resources/views/settings/relationships/home.blade.php @@ -3,23 +3,50 @@ @section('section')
-

Followers & Following

+

Relationships


-@if(empty($data)) -

You are not {{$mode == 'following' ? 'following anyone.' : 'followed by anyone.'}}

-@else
+@if(empty($data)) +

You are not {{$mode == 'hashtags' ? 'following any hashtags.' : ($mode == 'following' ? 'following anyone.' : 'followed by anyone.')}}

+@else
+ @if($mode == 'hashtags') + + + {{-- --}} + + + + + + @foreach($data as $hashtag) + + + + + @endforeach + @else {{-- @endforeach + @endif
+ + HashtagAction
+ +

#{{$hashtag->hashtag->name}}

+
+
+ Unfollow +
@@ -52,6 +79,7 @@ @endif
@@ -113,6 +141,17 @@ ); }); break; + + case 'unfollowhashtag': + axios.post('/api/local/discover/tag/subscribe', { + name: id + }).then(res => { + swal( + 'Unfollow Successful', + 'You have successfully unfollowed that hashtag', + 'success' + ); + }); } setTimeout(function() { window.location.href = window.location.href;