Skip to content

Commit

Permalink
fix query result usage
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyrAhmady committed Jan 15, 2024
1 parent f87fda1 commit 278ab94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/api/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ export const invoke_rpc = async (method: string, params: object) => {
Log.debug(`RPC request failed with status ${response.status}`);
}

return response.json();
const text = await response.text();
return text;
};
8 changes: 5 additions & 3 deletions src/containers/LoadingScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,11 @@ const LoadingScreen = (props: { onEnd: () => void }) => {
const list: any[] = [];
files.forEach((file: any) => collectFiles(file, list));

const checksums = (await invoke_rpc("get_checksum_of_files", {
list: list,
})) as string[];
const checksums: string[] = JSON.parse(
await invoke_rpc("get_checksum_of_files", {
list: list,
})
);

const results = await validateFileChecksums(checksums);
if (results.includes(false)) {
Expand Down
14 changes: 8 additions & 6 deletions src/utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const queryServer = (

const getServerInfo = async (ip: string, port: number, listType: ListType) => {
try {
const serverInfo: string = await invoke_rpc("request_server_info", {
const serverInfo: any = await invoke_rpc("request_server_info", {
ip: ip,
port: port,
});
Expand Down Expand Up @@ -199,16 +199,18 @@ const getServerOmpExtraInfo = async (

const getServerPing = async (ip: string, port: number, listType: ListType) => {
try {
const serverPing = await invoke_rpc("ping_server", {
ip: ip,
port: port,
});
const serverPing = parseInt(
await invoke_rpc("ping_server", {
ip: ip,
port: port,
})
);

let server = getServerFromList(ip, port, listType);
if (server) {
let ping = server.ping;

if (typeof serverPing === "number") {
if (!isNaN(serverPing)) {
if (serverPing !== 9999) {
ping = serverPing;
} else {
Expand Down

0 comments on commit 278ab94

Please sign in to comment.