diff --git a/app/src/store/session.ts b/app/src/store/session.ts index 3699ee2..8e21aa5 100644 --- a/app/src/store/session.ts +++ b/app/src/store/session.ts @@ -7,7 +7,7 @@ import api from '../utils/api' import Socket from '../utils/socket' import SocketTerminal from '../utils/terminal' import { LoadQuestError, LoadSessionError } from '../utils/errors' -import { Session } from '../types' +import { Session, StageResponse } from '../types' const toast = useToast() @@ -101,8 +101,12 @@ function updateGraph(event: { discover: FileObject[]; pwd: string }) { } } -function updateStatus(status: string) { - store.session.status = status +function newResponse(response: StageResponse) { + console.log('newResponse', response, 'session', store.session) + store.session.responses.push(...response.responses) + store.session.hints.push(...response.hints) + store.session.tasks = response.tasks + store.session.status = response.status } export function useTerminal() { @@ -143,8 +147,8 @@ function setup() { socket.on('graph', (event: { discover: FileObject[]; pwd: string }) => { updateGraph(event) }) - socket.on('status', (event: string) => { - updateStatus(event) + socket.on('response', (response: StageResponse) => { + newResponse(response) }) } diff --git a/app/src/types.ts b/app/src/types.ts index 7f01b6c..11a7b86 100644 --- a/app/src/types.ts +++ b/app/src/types.ts @@ -1,4 +1,6 @@ import { FileGraph } from '@linux-odyssey/file-graph' +// eslint-disable-next-line import/no-relative-packages +import { IResponse } from '../../packages/models/src/response' export interface Task { id: number @@ -6,6 +8,13 @@ export interface Task { completed: boolean } +export interface StageResponse { + status: string + hints: string[] + tasks: Task[] + responses: IResponse[] +} + export interface Session { _id: string status: string @@ -13,4 +22,5 @@ export interface Session { pwd: string hints: string[] tasks: Task[] + responses: IResponse[] }