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.php33
1 files changed, 17 insertions, 16 deletions
diff --git a/apps/updatenotification/lib/UpdateChecker.php b/apps/updatenotification/lib/UpdateChecker.php
index f15974a0318..b206ba4a3e4 100644
--- a/apps/updatenotification/lib/UpdateChecker.php
+++ b/apps/updatenotification/lib/UpdateChecker.php
@@ -4,25 +4,22 @@ declare(strict_types=1);
/**
* 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,
+ ) {
}
/**
@@ -59,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'] ?? '',
]);
}
}