diff --git a/resources/views/tracker.blade.php b/resources/views/tracker.blade.php index 673f7ba..33f7fcd 100644 --- a/resources/views/tracker.blade.php +++ b/resources/views/tracker.blade.php @@ -65,8 +65,8 @@ @endforeach - @if ($trip->is_active) -
+ @if (!$showAllCheckins) + @endif @@ -141,11 +141,6 @@ ).addTo(map).setZIndexOffset(1000); currLocation.bindPopup('Current location
').openPopup(); - /* - * Add all checkins link href. - */ - document.getElementById("allCheckinsLink").href = window.location.pathname + '/all'; - /* * Changes the currently-selected popup. */ diff --git a/routes/web.php b/routes/web.php index 7e0b8f7..9c78d25 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,38 +1,34 @@ input('show', null); + /* - * If there is a file in the local cache that is less than 5 hours old, + * If there is a file in the local cache that is less than 3 hours old, * use that. */ - $tripFileName = $tripId ?? config('app.current_trip_id') . '.json'; + $tripFileName = ( $tripId ?? config('app.current_trip_id') ) . '.json'; if (Storage::disk('local')->exists($tripFileName)) { $cachedData = json_decode(Storage::disk('local')->get($tripFileName)); - $cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at); - $now = new DateTime(); - if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 5) { - return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($showAll === 'all')]); + if ($cachedData->trip->is_active) { + $cachedDataUpdatedAt = new DateTime($cachedData->trip->updated_at); + $now = new DateTime(); + if (intval(($now->getTimestamp() - $cachedDataUpdatedAt->getTimestamp()) / 3600) <= 3) { + return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]); + } + } else { + return view('tracker', ['trip' => $cachedData->trip, 'showAllCheckins' => ($viewMode === 'all')]); } } @@ -61,8 +57,8 @@ Route::get('/{tripId?}/{showAll?}', function ($tripId = null, $showAll = false) } } - return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($showAll === 'all')]); + return view('tracker', ['trip' => $data->trip, 'showAllCheckins' => ($viewMode === 'all')]); } else { return 'Something went wrong'; } -}); +})->where('tripId', '[0-9a-z]{20}');