[Update/bugfix] To get software version.(show it to the console for now.)
fix the error that was wrong amount arguments.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useMainFunction } from "./useMainFunction";
|
||||
import { useConfig } from "./useConfig";
|
||||
|
||||
export const useReceiveRoutes = () => {
|
||||
const {
|
||||
@@ -7,22 +8,28 @@ export const useReceiveRoutes = () => {
|
||||
updateTranscriptionReceiveStatus,
|
||||
} = useMainFunction();
|
||||
|
||||
const {
|
||||
updateSoftwareVersion,
|
||||
} = useConfig();
|
||||
|
||||
const routes = {
|
||||
"/controller/callback_toggle_translation": updateTranslationStatus,
|
||||
"/controller/callback_toggle_transcription_send": updateTranscriptionSendStatus,
|
||||
"/controller/callback_toggle_transcription_receive": updateTranscriptionReceiveStatus,
|
||||
|
||||
"/config/version": updateSoftwareVersion,
|
||||
};
|
||||
|
||||
const receiveRoutes = (parsed_data) => {
|
||||
if (parsed_data.status === "ok") {
|
||||
const route = routes[parsed_data.id];
|
||||
if (parsed_data.status === 200) {
|
||||
const route = routes[parsed_data.endpoint];
|
||||
if (route) {
|
||||
route({ data: parsed_data.data });
|
||||
route({ data: parsed_data.result });
|
||||
} else {
|
||||
console.error(`Invalid path: ${parsed_data.id}`);
|
||||
console.error(`Invalid path: ${parsed_data.endpoint}`);
|
||||
}
|
||||
} else {
|
||||
console.log("Received data status is not 'ok'.", parsed_data);
|
||||
console.log("Received data status is not '200'.", parsed_data);
|
||||
}
|
||||
};
|
||||
return { receiveRoutes };
|
||||
|
||||
Reference in New Issue
Block a user