mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
commit
6d54f9b42e
5 changed files with 25 additions and 20 deletions
|
@ -83,20 +83,24 @@ class ApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
abort_if(!Auth::check(), 403);
|
abort_if(!Auth::check(), 403);
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'q' => 'required|string'
|
'q' => 'required|string|max:100'
|
||||||
]);
|
]);
|
||||||
$q = filter_var($request->input('q'), FILTER_SANITIZE_STRING);
|
$q = filter_var($request->input('q'), FILTER_SANITIZE_STRING);
|
||||||
$q = '%' . $q . '%';
|
$hash = hash('sha256', $q);
|
||||||
$places = Place::where('name', 'like', $q)
|
$key = 'search:location:id:' . $hash;
|
||||||
->take(25)
|
$places = Cache::remember($key, now()->addMinutes(15), function() use($q) {
|
||||||
->get()
|
$q = '%' . $q . '%';
|
||||||
->map(function($r) {
|
return Place::where('name', 'like', $q)
|
||||||
return [
|
->take(80)
|
||||||
'id' => $r->id,
|
->get()
|
||||||
'name' => $r->name,
|
->map(function($r) {
|
||||||
'country' => $r->country,
|
return [
|
||||||
'url' => $r->url()
|
'id' => $r->id,
|
||||||
];
|
'name' => $r->name,
|
||||||
|
'country' => $r->country,
|
||||||
|
'url' => $r->url()
|
||||||
|
];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
return $places;
|
return $places;
|
||||||
}
|
}
|
||||||
|
|
BIN
public/js/activity.js
vendored
BIN
public/js/activity.js
vendored
Binary file not shown.
BIN
public/js/timeline.js
vendored
BIN
public/js/timeline.js
vendored
Binary file not shown.
Binary file not shown.
|
@ -564,10 +564,7 @@
|
||||||
if(this.profile.is_admin == true) {
|
if(this.profile.is_admin == true) {
|
||||||
this.modes.mod = true;
|
this.modes.mod = true;
|
||||||
}
|
}
|
||||||
$('.profile-card .loader').addClass('d-none');
|
//this.expRec();
|
||||||
$('.profile-card .contents').removeClass('d-none');
|
|
||||||
$('.profile-card .card-footer').removeClass('d-none');
|
|
||||||
this.expRec();
|
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
swal(
|
swal(
|
||||||
'Oops, something went wrong',
|
'Oops, something went wrong',
|
||||||
|
@ -602,8 +599,8 @@
|
||||||
this.feed.push(...data);
|
this.feed.push(...data);
|
||||||
let ids = data.map(status => status.id);
|
let ids = data.map(status => status.id);
|
||||||
this.ids = ids;
|
this.ids = ids;
|
||||||
this.min_id = Math.max(...ids);
|
this.min_id = Math.max(...ids).toString();
|
||||||
this.max_id = Math.min(...ids);
|
this.max_id = Math.min(...ids).toString();
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
$('.timeline .pagination').removeClass('d-none');
|
$('.timeline .pagination').removeClass('d-none');
|
||||||
// if(this.feed.length == 4) {
|
// if(this.feed.length == 4) {
|
||||||
|
@ -626,6 +623,10 @@
|
||||||
$state.complete();
|
$state.complete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(this.page > 40) {
|
||||||
|
this.loading = false;
|
||||||
|
$state.complete();
|
||||||
|
}
|
||||||
let apiUrl = false;
|
let apiUrl = false;
|
||||||
switch(this.scope) {
|
switch(this.scope) {
|
||||||
case 'home':
|
case 'home':
|
||||||
|
@ -655,8 +656,8 @@
|
||||||
self.ids.push(d.id);
|
self.ids.push(d.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.min_id = Math.max(...this.ids);
|
this.min_id = Math.max(...this.ids).toString();
|
||||||
this.max_id = Math.min(...this.ids);
|
this.max_id = Math.min(...this.ids).toString();
|
||||||
this.page += 1;
|
this.page += 1;
|
||||||
$state.loaded();
|
$state.loaded();
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
|
|
Loading…
Reference in a new issue