Web: emit jobUpdate event with API object instead of straight JSON

Instead of just emitting the straight parsed-JSON object that the SocketIO
library gives us, feed it to the OpenAPI client type system to ensure it's
parsed in the same way as any regular API response.

This is mostly to get datetimes as JS `Date` object instead of as string.
This commit is contained in:
Sybren A. Stüvel 2022-04-12 15:43:50 +02:00
parent 48acf55d6b
commit caa3481561

@ -4,6 +4,7 @@
<script>
import io from "socket.io-client";
import * as API from "../manager-api"
export default {
emits: ["jobUpdate", "taskUpdate", "message", "reconnected"],
@ -47,7 +48,10 @@ export default {
});
this.socket.on("/jobs", (jobUpdate) => {
this.$emit("jobUpdate", jobUpdate);
// Convert to API object, in order to have the same parsing of data as
// when we'd do an API call.
const apiJobUpdate = API.JobUpdate.constructFromObject(jobUpdate)
this.$emit("jobUpdate", apiJobUpdate);
});
// Chat system, useful for debugging.