feat: pass headers correctly to downloadURL

This commit is contained in:
Zamitto 2024-08-05 15:21:05 -03:00
parent 070340b34f
commit e1ef8a9193
4 changed files with 18 additions and 9 deletions

View File

@ -26,6 +26,8 @@ const signOut = async (_event: Electron.IpcMainInvokeEvent) => {
/* Disconnects libtorrent */ /* Disconnects libtorrent */
PythonInstance.killTorrent(); PythonInstance.killTorrent();
HydraApi.handleSignOut();
await Promise.all([ await Promise.all([
databaseOperations, databaseOperations,
HydraApi.post("/auth/logout").catch(() => {}), HydraApi.post("/auth/logout").catch(() => {}),

View File

@ -45,15 +45,14 @@ export class HTTPDownload {
headers?: Record<string, string> headers?: Record<string, string>
) { ) {
return new Promise<string>((resolve) => { return new Promise<string>((resolve) => {
WindowManager.mainWindow?.webContents.downloadURL(downloadUrl, { const options = headers ? { headers } : {};
headers, WindowManager.mainWindow?.webContents.downloadURL(downloadUrl, options);
});
const gid = ++this.id;
WindowManager.mainWindow?.webContents.session.on( WindowManager.mainWindow?.webContents.session.on(
"will-download", "will-download",
(_event, item, _webContents) => { (_event, item, _webContents) => {
const gid = ++this.id;
this.downloads[gid.toString()] = item; this.downloads[gid.toString()] = item;
// Set the save path, making Electron not to prompt a save dialog. // Set the save path, making Electron not to prompt a save dialog.

View File

@ -64,6 +64,14 @@ export class HydraApi {
} }
} }
static handleSignOut() {
this.userAuth = {
authToken: "",
refreshToken: "",
expirationTimestamp: 0,
};
}
static async setupApi() { static async setupApi() {
this.instance = axios.create({ this.instance = axios.create({
baseURL: import.meta.env.MAIN_VITE_API_URL, baseURL: import.meta.env.MAIN_VITE_API_URL,

View File

@ -3751,10 +3751,10 @@ electron-vite@^2.0.0:
magic-string "^0.30.5" magic-string "^0.30.5"
picocolors "^1.0.0" picocolors "^1.0.0"
electron@^30.1.0: electron@^30.3.0:
version "30.3.0" version "30.3.1"
resolved "https://registry.yarnpkg.com/electron/-/electron-30.3.0.tgz#9d7af06c11242d5c6ca5b9920c9dc49feab90299" resolved "https://registry.yarnpkg.com/electron/-/electron-30.3.1.tgz#fe27ca2a4739bec832b2edd6f46140ab46bf53a0"
integrity sha512-/rWPcpCL4sYCUm1bY8if1dO8nyFTwXlPUP0dpL3ir5iLK/9NshN6lIJ8xceEY8CEYVLMIYRkxXb44Q9cdrjtOQ== integrity sha512-Ai/OZ7VlbFAVYMn9J5lyvtr+ZWyEbXDVd5wBLb5EVrp4352SRmMAmN5chcIe3n9mjzcgehV9n4Hwy15CJW+YbA==
dependencies: dependencies:
"@electron/get" "^2.0.0" "@electron/get" "^2.0.0"
"@types/node" "^20.9.0" "@types/node" "^20.9.0"