mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
fix: fix overwritten new response model
This commit is contained in:
1 parent
ebd713200c
commit
75f5407dde
2 files changed
+19
-5
No files matched your search
@@ -7,7 +7,7 @@ import api from '../utils/api'
|
|||||||
import Socket from '../utils/socket'
|
import Socket from '../utils/socket'
|
||||||
import SocketTerminal from '../utils/terminal'
|
import SocketTerminal from '../utils/terminal'
|
||||||
import { LoadQuestError, LoadSessionError } from '../utils/errors'
|
import { LoadQuestError, LoadSessionError } from '../utils/errors'
|
||||||
import { Session } from '../types'
|
import { Session, StageResponse } from '../types'
|
||||||
|
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
@@ -101,8 +101,12 @@ function updateGraph(event: { discover: FileObject[]; pwd: string }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStatus(status: string) {
|
function newResponse(response: StageResponse) {
|
||||||
store.session.status = status
|
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() {
|
export function useTerminal() {
|
||||||
@@ -143,8 +147,8 @@ function setup() {
|
|||||||
socket.on('graph', (event: { discover: FileObject[]; pwd: string }) => {
|
socket.on('graph', (event: { discover: FileObject[]; pwd: string }) => {
|
||||||
updateGraph(event)
|
updateGraph(event)
|
||||||
})
|
})
|
||||||
socket.on('status', (event: string) => {
|
socket.on('response', (response: StageResponse) => {
|
||||||
updateStatus(event)
|
newResponse(response)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { FileGraph } from '@linux-odyssey/file-graph'
|
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 {
|
export interface Task {
|
||||||
id: number
|
id: number
|
||||||
@@ -6,6 +8,13 @@ export interface Task {
|
|||||||
completed: boolean
|
completed: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface StageResponse {
|
||||||
|
status: string
|
||||||
|
hints: string[]
|
||||||
|
tasks: Task[]
|
||||||
|
responses: IResponse[]
|
||||||
|
}
|
||||||
|
|
||||||
export interface Session {
|
export interface Session {
|
||||||
_id: string
|
_id: string
|
||||||
status: string
|
status: string
|
||||||
@@ -13,4 +22,5 @@ export interface Session {
|
|||||||
pwd: string
|
pwd: string
|
||||||
hints: string[]
|
hints: string[]
|
||||||
tasks: Task[]
|
tasks: Task[]
|
||||||
|
responses: IResponse[]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user