diff --git a/app/Http/Controllers/ApiController.php b/app/Http/Controllers/ApiController.php index d71da8ce8..38e888644 100644 --- a/app/Http/Controllers/ApiController.php +++ b/app/Http/Controllers/ApiController.php @@ -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; } diff --git a/public/js/activity.js b/public/js/activity.js index d6e4fbad0..7d764b10e 100644 Binary files a/public/js/activity.js and b/public/js/activity.js differ diff --git a/public/js/timeline.js b/public/js/timeline.js index fe8a0582e..8bab66b0c 100644 Binary files a/public/js/timeline.js and b/public/js/timeline.js differ diff --git a/public/mix-manifest.json b/public/mix-manifest.json index abdb49fdb..7b819126e 100644 Binary files a/public/mix-manifest.json and b/public/mix-manifest.json differ diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index fdf8c1233..6de709a04 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -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;