diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2021-03-09 21:04:31 +0100 |
---|---|---|
committer | npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com> | 2021-03-22 20:31:56 +0000 |
commit | 8988406789c96db57044e56bbe01906878537b25 (patch) | |
tree | c7b13b9e946b42a4ed80bcc5b772248e49db9d46 /apps/comments/lib | |
parent | 90909ab9b9f2263e854788802794007a6d766356 (diff) | |
download | nextcloud-server-8988406789c96db57044e56bbe01906878537b25.tar.gz nextcloud-server-8988406789c96db57044e56bbe01906878537b25.zip |
Move comments to initial state
* Do not extend the jssettings
* Just use the proper intial state
* Use it in the js code as well
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
Diffstat (limited to 'apps/comments/lib')
-rw-r--r-- | apps/comments/lib/AppInfo/Application.php | 9 | ||||
-rw-r--r-- | apps/comments/lib/MaxAutoCompleteResultsInitialState.php (renamed from apps/comments/lib/JSSettingsHelper.php) | 29 |
2 files changed, 19 insertions, 19 deletions
diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php index 4eb097ff001..c152afddadd 100644 --- a/apps/comments/lib/AppInfo/Application.php +++ b/apps/comments/lib/AppInfo/Application.php @@ -31,10 +31,10 @@ use Closure; use OCA\Comments\Capabilities; use OCA\Comments\Controller\Notifications; use OCA\Comments\EventHandler; -use OCA\Comments\JSSettingsHelper; use OCA\Comments\Listener\CommentsEntityEventListener; use OCA\Comments\Listener\LoadAdditionalScripts; use OCA\Comments\Listener\LoadSidebarScripts; +use OCA\Comments\MaxAutoCompleteResultsInitialState; use OCA\Comments\Notification\Notifier; use OCA\Comments\Search\LegacyProvider; use OCA\Comments\Search\CommentsSearchProvider; @@ -45,10 +45,8 @@ use OCP\AppFramework\Bootstrap\IBootContext; use OCP\AppFramework\Bootstrap\IBootstrap; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\Comments\CommentsEntityEvent; -use OCP\IConfig; use OCP\ISearch; use OCP\IServerContainer; -use OCP\Util; class Application extends App implements IBootstrap { public const APP_ID = 'comments'; @@ -75,15 +73,14 @@ class Application extends App implements IBootstrap { CommentsEntityEventListener::class ); $context->registerSearchProvider(CommentsSearchProvider::class); + + $context->registerInitialStateProvider(MaxAutoCompleteResultsInitialState::class); } public function boot(IBootContext $context): void { $context->injectFn(Closure::fromCallable([$this, 'registerNotifier'])); $context->injectFn(Closure::fromCallable([$this, 'registerCommentsEventHandler'])); - $jsSettingsHelper = new JSSettingsHelper($context->getAppContainer()->get(IConfig::class)); - Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend'); - $context->getServerContainer()->get(ISearch::class)->registerProvider(LegacyProvider::class, ['apps' => ['files']]); } diff --git a/apps/comments/lib/JSSettingsHelper.php b/apps/comments/lib/MaxAutoCompleteResultsInitialState.php index 19e4392d0b7..62a1cb42e24 100644 --- a/apps/comments/lib/JSSettingsHelper.php +++ b/apps/comments/lib/MaxAutoCompleteResultsInitialState.php @@ -1,9 +1,11 @@ <?php + +declare(strict_types=1); + /** - * @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de> + * @copyright Copyright (c) 2021 Roeland Jago Douma <roeland@famdouma.nl> * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> + * @author Roeland Jago Douma <roeland@famdouma.nl> * * @license GNU AGPL version 3 or any later version * @@ -24,22 +26,23 @@ namespace OCA\Comments; +use OCP\AppFramework\Services\InitialStateProvider; use OCP\IConfig; -class JSSettingsHelper { +class MaxAutoCompleteResultsInitialState extends InitialStateProvider { + /** @var IConfig */ - private $c; + private $config; - public function __construct(IConfig $c) { - $this->c = $c; + public function __construct(IConfig $config) { + $this->config = $config; } - public function extend(array $settings) { - $appConfig = json_decode($settings['array']['oc_appconfig'], true); - - $value = (int)$this->c->getAppValue('comments', 'maxAutoCompleteResults', 10); - $appConfig['comments']['maxAutoCompleteResults'] = $value; + public function getKey(): string { + return 'maxAutoCompleteResults'; + } - $settings['array']['oc_appconfig'] = json_encode($appConfig); + public function getData(): int { + return (int)$this->config->getAppValue('comments', 'maxAutoCompleteResults', '10'); } } |