Skip to content

Commit

Permalink
🐛 remove parsing response
Browse files Browse the repository at this point in the history
  • Loading branch information
sestinj committed Jun 13, 2024
1 parent cba60c4 commit e2a90ae
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions gui/src/context/IdeMessenger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,6 @@ export class IdeMessenger implements IIdeMessenger {
this._postToIde(messageType, data, messageId);
}

private _safeParseResponse(data: any) {
// This causes .json files to be parsed as objects instead of remaining strings
let responseData = data ?? null;
try {
responseData = JSON.parse(responseData);
} catch {}
return responseData;
}

request<T extends keyof FromWebviewProtocol>(
messageType: T,
data: FromWebviewProtocol[T][0],
Expand All @@ -139,7 +130,8 @@ export class IdeMessenger implements IIdeMessenger {
const handler = (event: any) => {
if (event.data.messageId === messageId) {
window.removeEventListener("message", handler);
resolve(this._safeParseResponse(event.data.data));
console.log(typeof event.data.data);
resolve(event.data.data);
}
};
window.addEventListener("message", handler);
Expand All @@ -164,7 +156,8 @@ export class IdeMessenger implements IIdeMessenger {

const handler = (event: { data: Message }) => {
if (event.data.messageId === messageId) {
const responseData = this._safeParseResponse(event.data.data);
console.log("BB", typeof event.data.data);
const responseData = event.data.data;
if (responseData.done) {
window.removeEventListener("message", handler);
done = true;
Expand Down

0 comments on commit e2a90ae

Please sign in to comment.