Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions app/Http/Middleware/CheckVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ class CheckVersion
*/
public function handle($request, Closure $next)
{
$instance = Instance::first();
if (($version = config('monica.app_version')) !== '') {
$instance = Instance::first();

$appVersion = new Version(config('monica.app_version'));
$latestVersion = new Version($instance->latest_version ?? '0.0.0');
$currentVersion = new Version($instance->current_version ?? '0.0.0');
$appVersion = new Version($version);
$latestVersion = new Version($instance->latest_version ?? '0.0.0');
$currentVersion = new Version($instance->current_version ?? '0.0.0');

if ($latestVersion == $appVersion && $currentVersion != $latestVersion) {
if ($latestVersion == $appVersion && $currentVersion != $latestVersion) {

// The instance has been updated to the latest version. We reset
// the ping data.
// The instance has been updated to the latest version. We reset
// the ping data.

$instance->current_version = $instance->latest_version;
$instance->latest_release_notes = null;
$instance->number_of_versions_since_current_version = null;
$instance->save();
$instance->current_version = $instance->latest_version;
$instance->latest_release_notes = null;
$instance->number_of_versions_since_current_version = null;
$instance->save();
}
}

return $next($request);
Expand Down
2 changes: 1 addition & 1 deletion resources/views/partials/check.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@if (config('monica.check_version'))

@if (version_compare($instance->latest_version, config('monica.app_version')) > 0)
@if (($version = config('monica.app_version')) !== '' && version_compare($instance->latest_version, $version) > 0)
<li>
<a href="#showVersion" data-toggle="modal" class="badge badge-success">{{ trans('app.footer_new_version') }}</a>
</li>
Expand Down
4 changes: 3 additions & 1 deletion resources/views/partials/footer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
<ul>
<li class="di"><a href="https://monicahq.com/changelog" hreflang="en">{{ trans('app.footer_release') }}</a></li>
<li class="di ml2"><a href="https://github.com/monicahq/monica">{{ trans('app.footer_source_code') }}</a></li>
<li class="di ml2">{{ trans('app.footer_version', ['version' => config('monica.app_version')]) }}</li>
@if (($version = config('monica.app_version')) !== '')
<li class="di ml2">{{ trans('app.footer_version', ['version' => $version]) }}</li>
@endif

@include('partials.check')
</ul>
Expand Down