Skip to content

Commit

Permalink
feat: Add feature flag for notify push to test on nightly more easily
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr committed Jun 13, 2024
1 parent 3af8768 commit 3570db2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
class ApiService {
public function __construct(
private IRequest $request,
private ConfigService $configService,
private SessionService $sessionService,
private DocumentService $documentService,
private EncodingService $encodingService,
Expand Down Expand Up @@ -207,7 +208,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;
}

Expand Down
5 changes: 5 additions & 0 deletions lib/Service/ConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,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');

}
}
5 changes: 5 additions & 0 deletions lib/Service/InitialStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ public function provideState(): void {
];
}, $this->textProcessingManager->getAvailableTaskTypes()),
);

$this->initialState->provideInitialState(
'notify_push',
$this->configService->isNotifyPushSyncEnabled(),
);
}

public function provideFileId(int $fileId): void {
Expand Down
10 changes: 7 additions & 3 deletions src/services/NotifyService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 3570db2

Please sign in to comment.