Skip to content

Commit

Permalink
updated manifest to use electron's net module instead of native `fe…
Browse files Browse the repository at this point in the history
…tch`
  • Loading branch information
jgaribsin committed Jul 18, 2024
1 parent b93482d commit b4b0f9a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src-electron/ipcListeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
dialog as ElectronDialog,
shell as ElectronShell,
ipcMain,
net,
} from 'electron';
const { spawn } = require('child_process');
const os = require('os');
Expand Down Expand Up @@ -108,8 +109,25 @@ ipcMain.handle('getDrehmalPath', () => {
});

ipcMain.handle('getManifestData', async (_event, url) => {
const response = await fetch(url);
return await response.json();
return new Promise((resolve, reject) => {
const request = net.request(url);

request.on('response', (response) => {
let data = '';
response.on('data', (chunk) => {
data += chunk;
});
response.on('end', () => {
resolve(JSON.parse(data));
});
});

request.on('error', (error) => {
reject(error);
});

request.end();
});
});

ipcMain.handle(
Expand Down

0 comments on commit b4b0f9a

Please sign in to comment.