Merge pull request #1214 from pixelfed/frontend-ui-refactor

Frontend ui refactor
This commit is contained in:
daniel 2019-04-28 22:38:37 -06:00 committed by GitHub
commit f1a682611d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 62 additions and 27 deletions

View file

@ -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();
}

View file

@ -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'

View file

@ -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,34 +42,23 @@ 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;
}
}
if($request->has('profile_suggestions')) {
if($profile->is_suggestable == false) {
$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);
}
}
if($changes == true) {
$profile->save();

View file

@ -397,6 +397,14 @@
{{user.display_name}}
</p>
</div>
<div v-if="owner">
<a class="btn btn-outline-secondary btn-sm" href="#" @click.prevent="followModalAction(user.id, index, 'following')">Unfollow</a>
</div>
</div>
</div>
<div v-if="following.length == 0" class="list-group-item border-0">
<div class="list-group-item border-0">
<p class="p-3 text-center mb-0 lead">You are not following anyone.</p>
</div>
</div>
<div v-if="followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
@ -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--;
}
})
}
}
}

View file

@ -287,9 +287,15 @@
{{user.display_name}}
</p>
</div>
<a class="btn btn-outline-secondary btn-sm" href="#" @click.prevent="followModalAction(user.id, index, 'following')">Unfollow</a>
</div>
</div>
<div v-if="followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
<div v-if="following.length == 0" class="list-group-item border-0">
<div class="list-group-item border-0">
<p class="p-3 text-center mb-0 lead">You are not following anyone.</p>
</div>
</div>
<div v-if="following.length != 0 && followingMore" class="list-group-item text-center" v-on:click="followingLoadMore()">
<p class="mb-0 small text-muted font-weight-light cursor-pointer">Load more</p>
</div>
</div>
@ -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);
}
})
}
}
}

View file

@ -31,7 +31,6 @@
</label>
<p class="text-muted small help-text">MomentUI offers an alternative layout for posts and your profile.</p>
</div>
@if($profile->profile_layout != 'moment')
<div class="form-check pb-3">
<input class="form-check-input" type="checkbox" name="dark_mode" id="dark_mode" {{request()->hasCookie('dark-mode') ? 'checked':''}}>
<label class="form-check-label font-weight-bold" for="dark_mode">
@ -39,7 +38,6 @@
</label>
<p class="text-muted small help-text">Use dark mode theme.</p>
</div>
@endif
<div class="py-3">
<p class="font-weight-bold text-muted text-center">Discovery</p>
<hr>