forked from mirror/pixelfed
commit
6d54f9b42e
5 changed files with 29 additions and 24 deletions
|
@ -83,20 +83,24 @@ class ApiController extends BaseApiController
|
|||
{
|
||||
abort_if(!Auth::check(), 403);
|
||||
$this->validate($request, [
|
||||
'q' => 'required|string'
|
||||
'q' => 'required|string|max:100'
|
||||
]);
|
||||
$q = filter_var($request->input('q'), FILTER_SANITIZE_STRING);
|
||||
$q = '%' . $q . '%';
|
||||
$places = Place::where('name', 'like', $q)
|
||||
->take(25)
|
||||
->get()
|
||||
->map(function($r) {
|
||||
return [
|
||||
'id' => $r->id,
|
||||
'name' => $r->name,
|
||||
'country' => $r->country,
|
||||
'url' => $r->url()
|
||||
];
|
||||
$hash = hash('sha256', $q);
|
||||
$key = 'search:location:id:' . $hash;
|
||||
$places = Cache::remember($key, now()->addMinutes(15), function() use($q) {
|
||||
$q = '%' . $q . '%';
|
||||
return Place::where('name', 'like', $q)
|
||||
->take(80)
|
||||
->get()
|
||||
->map(function($r) {
|
||||
return [
|
||||
'id' => $r->id,
|
||||
'name' => $r->name,
|
||||
'country' => $r->country,
|
||||
'url' => $r->url()
|
||||
];
|
||||
});
|
||||
});
|
||||
return $places;
|
||||
}
|
||||
|
|
2
public/js/activity.js
vendored
2
public/js/activity.js
vendored
File diff suppressed because one or more lines are too long
2
public/js/timeline.js
vendored
2
public/js/timeline.js
vendored
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,7 @@
|
|||
"/js/manifest.js": "/js/manifest.js?id=01c8731923a46c30aaed",
|
||||
"/js/vendor.js": "/js/vendor.js?id=fac92a458473b287c543",
|
||||
"/js/ace.js": "/js/ace.js?id=585114d8896dc0c24020",
|
||||
"/js/activity.js": "/js/activity.js?id=8e06ae08d7c087c53045",
|
||||
"/js/activity.js": "/js/activity.js?id=713d9542e71e87fb88c0",
|
||||
"/js/app.js": "/js/app.js?id=e44ab72ffa230a7a56c1",
|
||||
"/css/app.css": "/css/app.css?id=67710dadf879498b096a",
|
||||
"/css/appdark.css": "/css/appdark.css?id=6c52e68ca396700f0836",
|
||||
|
@ -23,5 +23,5 @@
|
|||
"/js/search.js": "/js/search.js?id=f312959df65e86a307a3",
|
||||
"/js/status.js": "/js/status.js?id=27f13302db3fec70f5de",
|
||||
"/js/theme-monokai.js": "/js/theme-monokai.js?id=700e5dc735365e184e41",
|
||||
"/js/timeline.js": "/js/timeline.js?id=975d74312cbfec350959"
|
||||
"/js/timeline.js": "/js/timeline.js?id=5c63858925484f87064f"
|
||||
}
|
||||
|
|
|
@ -564,10 +564,7 @@
|
|||
if(this.profile.is_admin == true) {
|
||||
this.modes.mod = true;
|
||||
}
|
||||
$('.profile-card .loader').addClass('d-none');
|
||||
$('.profile-card .contents').removeClass('d-none');
|
||||
$('.profile-card .card-footer').removeClass('d-none');
|
||||
this.expRec();
|
||||
//this.expRec();
|
||||
}).catch(err => {
|
||||
swal(
|
||||
'Oops, something went wrong',
|
||||
|
@ -602,8 +599,8 @@
|
|||
this.feed.push(...data);
|
||||
let ids = data.map(status => status.id);
|
||||
this.ids = ids;
|
||||
this.min_id = Math.max(...ids);
|
||||
this.max_id = Math.min(...ids);
|
||||
this.min_id = Math.max(...ids).toString();
|
||||
this.max_id = Math.min(...ids).toString();
|
||||
this.loading = false;
|
||||
$('.timeline .pagination').removeClass('d-none');
|
||||
// if(this.feed.length == 4) {
|
||||
|
@ -626,6 +623,10 @@
|
|||
$state.complete();
|
||||
return;
|
||||
}
|
||||
if(this.page > 40) {
|
||||
this.loading = false;
|
||||
$state.complete();
|
||||
}
|
||||
let apiUrl = false;
|
||||
switch(this.scope) {
|
||||
case 'home':
|
||||
|
@ -655,8 +656,8 @@
|
|||
self.ids.push(d.id);
|
||||
}
|
||||
});
|
||||
this.min_id = Math.max(...this.ids);
|
||||
this.max_id = Math.min(...this.ids);
|
||||
this.min_id = Math.max(...this.ids).toString();
|
||||
this.max_id = Math.min(...this.ids).toString();
|
||||
this.page += 1;
|
||||
$state.loaded();
|
||||
this.loading = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue