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 <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Jul 18, 2024
1 parent e5907c9 commit f352174
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 @@ -35,6 +35,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 @@ -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;
}

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

}
}
5 changes: 5 additions & 0 deletions lib/Service/InitialStateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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 f352174

Please sign in to comment.