Skip to content

Commit

Permalink
fix: version display on heroku (#5860)
Browse files Browse the repository at this point in the history
  • Loading branch information
asbiin committed Jan 9, 2022
1 parent 9c2bba1 commit 0cf965f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
24 changes: 13 additions & 11 deletions app/Http/Middleware/CheckVersion.php
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
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
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

0 comments on commit 0cf965f

Please sign in to comment.