Improve update detection

This commit is contained in:
grandeljay 2022-03-05 10:11:30 +01:00
parent e5b7dd203a
commit 5e69a6bc77
4 changed files with 3 additions and 4 deletions

View file

@ -95,7 +95,7 @@ if ($options && !isset($_POST['install'])) {
$version = str_replace('v', '', $tag);
if (-1 === version_compare($options->version, $version)) {
$options->updateAvailable = true;
$options->setOption('updateAvailable', true);
}
} catch (\Github\Exception\RuntimeException $th) {
echo wishthis\Page::warning($th->getMessage());

View file

@ -12,8 +12,6 @@ namespace wishthis;
class Options
{
public bool $updateAvailable = false;
public string $version;
public function __construct(private Database $database)

View file

@ -321,7 +321,7 @@ class Page
global $options;
if ($options->updateAvailable && $user && 100 === $user->power) {
if ($options->getOption('updateAvailable') && $user && 100 === $user->power) {
$pages['system']['items'][] = array(
'url' => '/?page=update',
'text' => 'Update',

View file

@ -88,6 +88,7 @@ if ('POST' === $_SERVER['REQUEST_METHOD']) {
/** Update version */
$options->setOption('version', $version);
$options->setOption('updateAvailable', false);
header('Location: /?page=home');
die();