Loading frontend/src/pages/trainee/[exerciseId]/[teamId]/_layout.tsx +8 −4 Original line number Diff line number Diff line Loading @@ -30,16 +30,20 @@ const Layout = () => { [showPopup] ) useEventListener('actionLogEvent', e => { const newActionLog = e.detail.actionLog const { actionLog, eventType } = e.detail switch (newActionLog.details.__typename) { if (eventType !== 'CREATE') { return } switch (actionLog.details.__typename) { case 'InjectDetailsType': case 'CustomInjectDetailsType': case 'EmailType': handleOverlay(newActionLog, newActionLog.details.overlay) handleOverlay(actionLog, actionLog.details.overlay) break case 'TeamQuestionnaireStateType': handleOverlay(newActionLog, newActionLog.details.questionnaire.overlay) handleOverlay(actionLog, actionLog.details.questionnaire.overlay) break default: break Loading graphql/urql/events.d.ts +2 −3 Original line number Diff line number Diff line import { FragmentOf } from 'gql.tada' import { ActionLog } from '../fragments' import { EventType } from './cache-typing' declare global { interface WindowEventMap { Loading @@ -9,11 +10,9 @@ declare global { } } // Note: payload behaves differently depending on subscription/trainee.ts and subscription/instructor.ts // instructor currently receives the payload whenever any change occurs // trainee receives the payload only when a new actionlog comes in export type ActionLogPayload = { actionLog: FragmentOf<typeof ActionLog> eventType: EventType } export {} //keep that for TS compiler. graphql/utils/Subscriptions/instructor.ts +2 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ const useActionLogSubscriptionInstructor = ({ } const { unsubscribe: unsubLog } = client .subscription(exerciseActionLogs, { .subscription<ResultOf<typeof exerciseActionLogs>>(exerciseActionLogs, { exerciseId, }) .subscribe(({ data }) => { Loading @@ -76,6 +76,7 @@ const useActionLogSubscriptionInstructor = ({ new CustomEvent<ActionLogPayload>('actionLogEvent', { detail: { actionLog: data.analyticsActionLogsSubscription.actionLog, eventType: data.analyticsActionLogsSubscription.eventType, }, }) ) Loading graphql/utils/Subscriptions/trainee.ts +1 −3 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ import { teamAction } from '../../subscriptions' import { useClient } from '../../urql/client' import type { ActionLogPayload } from '../../urql/events' import useExerciseLoopStatusSubscription from '../useExerciseLoopStatusSubscription' import { useGenericActionLogEvent } from './utils' const useActionLogSubscriptionTrainee = ({ teamId, Loading Loading @@ -49,6 +48,7 @@ const useActionLogSubscriptionTrainee = ({ new CustomEvent<ActionLogPayload>('actionLogEvent', { detail: { actionLog: data.actionLogs.actionLog, eventType: data.actionLogs.eventType, }, }) ) Loading @@ -59,8 +59,6 @@ const useActionLogSubscriptionTrainee = ({ unsubLog() } }, [client, exerciseId, teamId]) useGenericActionLogEvent() } export default useActionLogSubscriptionTrainee Loading
frontend/src/pages/trainee/[exerciseId]/[teamId]/_layout.tsx +8 −4 Original line number Diff line number Diff line Loading @@ -30,16 +30,20 @@ const Layout = () => { [showPopup] ) useEventListener('actionLogEvent', e => { const newActionLog = e.detail.actionLog const { actionLog, eventType } = e.detail switch (newActionLog.details.__typename) { if (eventType !== 'CREATE') { return } switch (actionLog.details.__typename) { case 'InjectDetailsType': case 'CustomInjectDetailsType': case 'EmailType': handleOverlay(newActionLog, newActionLog.details.overlay) handleOverlay(actionLog, actionLog.details.overlay) break case 'TeamQuestionnaireStateType': handleOverlay(newActionLog, newActionLog.details.questionnaire.overlay) handleOverlay(actionLog, actionLog.details.questionnaire.overlay) break default: break Loading
graphql/urql/events.d.ts +2 −3 Original line number Diff line number Diff line import { FragmentOf } from 'gql.tada' import { ActionLog } from '../fragments' import { EventType } from './cache-typing' declare global { interface WindowEventMap { Loading @@ -9,11 +10,9 @@ declare global { } } // Note: payload behaves differently depending on subscription/trainee.ts and subscription/instructor.ts // instructor currently receives the payload whenever any change occurs // trainee receives the payload only when a new actionlog comes in export type ActionLogPayload = { actionLog: FragmentOf<typeof ActionLog> eventType: EventType } export {} //keep that for TS compiler.
graphql/utils/Subscriptions/instructor.ts +2 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ const useActionLogSubscriptionInstructor = ({ } const { unsubscribe: unsubLog } = client .subscription(exerciseActionLogs, { .subscription<ResultOf<typeof exerciseActionLogs>>(exerciseActionLogs, { exerciseId, }) .subscribe(({ data }) => { Loading @@ -76,6 +76,7 @@ const useActionLogSubscriptionInstructor = ({ new CustomEvent<ActionLogPayload>('actionLogEvent', { detail: { actionLog: data.analyticsActionLogsSubscription.actionLog, eventType: data.analyticsActionLogsSubscription.eventType, }, }) ) Loading
graphql/utils/Subscriptions/trainee.ts +1 −3 Original line number Diff line number Diff line Loading @@ -6,7 +6,6 @@ import { teamAction } from '../../subscriptions' import { useClient } from '../../urql/client' import type { ActionLogPayload } from '../../urql/events' import useExerciseLoopStatusSubscription from '../useExerciseLoopStatusSubscription' import { useGenericActionLogEvent } from './utils' const useActionLogSubscriptionTrainee = ({ teamId, Loading Loading @@ -49,6 +48,7 @@ const useActionLogSubscriptionTrainee = ({ new CustomEvent<ActionLogPayload>('actionLogEvent', { detail: { actionLog: data.actionLogs.actionLog, eventType: data.actionLogs.eventType, }, }) ) Loading @@ -59,8 +59,6 @@ const useActionLogSubscriptionTrainee = ({ unsubLog() } }, [client, exerciseId, teamId]) useGenericActionLogEvent() } export default useActionLogSubscriptionTrainee