Skip to content

Commit 1c004b4

Browse files
release-v-1-15-0 (#17)
* missing web sockets messages * Adds org id to hook --------- Co-authored-by: JWittmeyer <jens.wittmeyer@kern.ai>
1 parent 01f2ee4 commit 1c004b4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

hooks/web-socket/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const WHITELIST_LOOKUP_REFINERY = {
104104
[CurrentPageSubKey.NONE]: ['labeling_task_updated', 'labeling_task_created', 'label_created', 'label_deleted', 'labeling_task_deleted', 'information_source_deleted', 'information_source_updated', 'model_callback_update_statistics', 'embedding_deleted', 'embedding', 'payload_finished', 'payload_failed', 'payload_created', 'payload_update_statistics']
105105
},
106106
[CurrentPage.HEURISTICS]: {
107-
[CurrentPageSubKey.NONE]: ['labeling_task_updated', 'labeling_task_created', 'labeling_task_deleted', 'information_source_created', 'information_source_updated', 'information_source_deleted', 'payload_finished', 'payload_failed', 'payload_created', 'payload_update_statistics', 'embedding_deleted'],
107+
[CurrentPageSubKey.NONE]: ['labeling_task_updated', 'labeling_task_created', 'labeling_task_deleted', 'information_source_created', 'information_source_updated', 'information_source_deleted', 'payload_finished', 'payload_failed', 'payload_created', 'payload_update_statistics', 'embedding_deleted', 'weak_supervision_started', 'weak_supervision_finished'],
108108

109109
},
110110
[CurrentPage.EDIT_RECORDS]: {

hooks/web-socket/useWebsocket.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { WebSocketsService } from './WebSocketsService';
33
import { NotificationSubscription, getConstWhitelist } from './web-sockets-helper';
44
import { Application, CurrentPage, CurrentPageSubKey } from './constants';
55

6-
export function useWebsocket(application: Application, currentPage: CurrentPage, handleFunction: (msgParts: string[]) => void, projectId?: string, subKey?: CurrentPageSubKey) {
6+
export function useWebsocket(userOrgId: string, application: Application, currentPage: CurrentPage, handleFunction: (msgParts: string[]) => void, projectId?: string, subKey?: CurrentPageSubKey) {
77

88
const _projectId = useMemo(() => projectId || "GLOBAL", [projectId]);
99
const _subKey = useMemo(() => subKey || CurrentPageSubKey.NONE, [subKey]);
1010
const __whitelist = useMemo(() => getConstWhitelist(application), [application]);
11-
1211
useEffect(() => {
12+
if (!userOrgId) return;
1313
if (!__whitelist[currentPage]) {
1414
console.error(`The combination of ${currentPage} and ${application} does not exist in the whitelist`);
1515
return;
@@ -22,12 +22,13 @@ export function useWebsocket(application: Application, currentPage: CurrentPage,
2222

2323
WebSocketsService.subscribeToNotification(currentPage, nos, _subKey);
2424

25-
return () => WebSocketsService.unsubscribeFromNotification(currentPage, projectId, _subKey);
26-
}, [_projectId, _subKey, application]);
25+
return () => { if (userOrgId) WebSocketsService.unsubscribeFromNotification(currentPage, projectId, _subKey) };
26+
}, [userOrgId, _projectId, _subKey, application]);
2727

2828
useEffect(() => {
29+
if (!userOrgId) return;
2930
WebSocketsService.updateFunctionPointer(projectId, currentPage, handleFunction, subKey)
30-
}, [handleFunction]);
31+
}, [userOrgId, handleFunction]);
3132

3233

3334
}

0 commit comments

Comments
 (0)