aboutsummaryrefslogtreecommitdiffstats
path: root/apps/updatenotification/lib/UpdateChecker.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/updatenotification/lib/UpdateChecker.php')
-rw-r--r--apps/updatenotification/lib/UpdateChecker.php57
1 files changed, 19 insertions, 38 deletions
diff --git a/apps/updatenotification/lib/UpdateChecker.php b/apps/updatenotification/lib/UpdateChecker.php
index 40bf784e605..b206ba4a3e4 100644
--- a/apps/updatenotification/lib/UpdateChecker.php
+++ b/apps/updatenotification/lib/UpdateChecker.php
@@ -3,46 +3,23 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\UpdateNotification;
use OC\Updater\ChangesCheck;
use OC\Updater\VersionCheck;
+use OCP\AppFramework\Services\IInitialState;
class UpdateChecker {
- /** @var VersionCheck */
- private $updater;
- /** @var ChangesCheck */
- private $changesCheck;
- /**
- * @param VersionCheck $updater
- */
- public function __construct(VersionCheck $updater, ChangesCheck $changesCheck) {
- $this->updater = $updater;
- $this->changesCheck = $changesCheck;
+ public function __construct(
+ private VersionCheck $updater,
+ private ChangesCheck $changesCheck,
+ private IInitialState $initialState,
+ ) {
}
/**
@@ -79,13 +56,17 @@ class UpdateChecker {
}
/**
- * @param array $data
+ * Provide update information as initial state
*/
- public function populateJavaScriptVariables(array $data) {
- $data['array']['oc_updateState'] = json_encode([
- 'updateAvailable' => true,
- 'updateVersion' => $this->getUpdateState()['updateVersionString'],
- 'updateLink' => $this->getUpdateState()['updateLink'] ?? '',
+ public function setInitialState(): void {
+ $updateState = $this->getUpdateState();
+ if (empty($updateState)) {
+ return;
+ }
+
+ $this->initialState->provideInitialState('updateState', [
+ 'updateVersion' => $updateState['updateVersionString'],
+ 'updateLink' => $updateState['updateLink'] ?? '',
]);
}
}