diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php index 706968f4512..724fb43e835 100644 --- a/lib/Service/ApiService.php +++ b/lib/Service/ApiService.php @@ -35,6 +35,7 @@ class ApiService { public function __construct( private IRequest $request, + private ConfigService $configService, private SessionService $sessionService, private DocumentService $documentService, private EncodingService $encodingService, @@ -193,7 +194,7 @@ public function push(Session $session, Document $document, int $version, array $ } private function addToPushQueue(Document $document, array $steps): void { - if ($this->queue === null) { + if ($this->queue === null || !$this->configService->isNotifyPushSyncEnabled()) { return; } diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index ff3c11e0267..0fd85cb8f80 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -39,4 +39,9 @@ public function isRichWorkspaceEnabledForUser(?string $userId): bool { } return $this->config->getUserValue($userId, Application::APP_NAME, 'workspace_enabled', '1') === '1'; } + + public function isNotifyPushSyncEnabled(): bool { + return $this->appConfig->getValueBool(Application::APP_NAME, 'notify_push'); + + } } diff --git a/lib/Service/InitialStateProvider.php b/lib/Service/InitialStateProvider.php index e49ef97802b..453e2b39447 100644 --- a/lib/Service/InitialStateProvider.php +++ b/lib/Service/InitialStateProvider.php @@ -64,6 +64,11 @@ public function provideState(): void { ]; }, $this->textProcessingManager->getAvailableTaskTypes()), ); + + $this->initialState->provideInitialState( + 'notify_push', + $this->configService->isNotifyPushSyncEnabled(), + ); } public function provideFileId(int $fileId): void { diff --git a/src/services/NotifyService.js b/src/services/NotifyService.js index e5608613215..355ae7e9cfd 100644 --- a/src/services/NotifyService.js +++ b/src/services/NotifyService.js @@ -21,11 +21,15 @@ import mitt from 'mitt' import { listen } from '@nextcloud/notify_push' +import { loadState } from '@nextcloud/initial-state' if (!window._nc_text_notify) { - const useNotifyPush = listen('text_steps', (messageType, messageBody) => { - window._nc_text_notify?.emit('notify_push', { messageType, messageBody }) - }) + const isPushEnabled = loadState('text', 'notify_push', false) + const useNotifyPush = isPushEnabled + ? listen('text_steps', (messageType, messageBody) => { + window._nc_text_notify?.emit('notify_push', { messageType, messageBody }) + }) + : undefined window._nc_text_notify = useNotifyPush ? mitt() : null }