Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
fix: various type and logic errors
Browse files Browse the repository at this point in the history
  • Loading branch information
coredev-uk committed Dec 10, 2024
1 parent 7c44535 commit c4c084e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/main/base/browserwindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ export class BrowserWindow {
if (url.endsWith("/")) url = url.slice(0, -1);
let response = await utils.fetch(`${url}/archive/refs/heads/main.zip`);
let repo = url.split("/").slice(-2).join("/");
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json()) as { id: number};
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json()) as { id: number };
console.debug(`REPO ID: ${apiRepo.id}`);
// extract the files from the first folder in the zip response
let zip = new AdmZip(await response.buffer());
Expand Down Expand Up @@ -927,7 +927,7 @@ export class BrowserWindow {
"User-Agent": utils.getWindow().webContents.getUserAgent(),
},
})
.then((res) => res.json()) as { id: number}
.then((res) => res.json()) as { id: number }
console.error(apiRepo);
console.debug(`REPO ID: ${apiRepo.id}`);
// extract the files from the first folder in the zip response
Expand Down Expand Up @@ -1206,7 +1206,7 @@ export class BrowserWindow {

var inputIndex = 0;

for (var index = 0; index < length; ) {
for (var index = 0; index < length;) {
result[index++] = leftChannel[inputIndex];
result[index++] = rightChannel[inputIndex];
inputIndex++;
Expand Down Expand Up @@ -1300,7 +1300,10 @@ export class BrowserWindow {
//let newaudio = [leftpcm, rightpcm];
// console.log(newaudio.length);

let pcmData = Buffer.from(new Int8Array(interleave16(bitratechange(Int16Array.from(newaudio[0], (x) => convert(x))), bitratechange(Int16Array.from(newaudio[1], (x) => convert(x)))).buffer));
const pcmData = Buffer.from(new Uint8Array(interleave16(
bitratechange(Int16Array.from(newaudio[0], (x) => convert(x))),
bitratechange(Int16Array.from(newaudio[1], (x) => convert(x)))
).buffer));

if (!this.headerSent) {
console.log("new header");
Expand Down
5 changes: 3 additions & 2 deletions src/main/base/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ export class utils {
*/
static getLocale(language: string, key?: string): string | object {
let i18n: any = {};

if (!this.i18n[language]) {
i18n = this.i18n["en"][0].content;
i18n = this.i18n["en-US"][0].content;
} else {
i18n = this.i18n[language ?? "en"][0].content;
i18n = this.i18n[language ?? "en-US"][0].content;
}

if (key) {
Expand Down
11 changes: 6 additions & 5 deletions src/main/plugins/chromecast.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import electron from "electron";
import os from "os";
import {CiderReceiver} from "../base/castreceiver.js";
import { CiderReceiver } from "../base/castreceiver.js";
import MediaRendererClient from "upnp-mediarenderer-client";
import request from "request";
// @ts-expect-error

Check failure on line 6 in src/main/plugins/chromecast.ts

View workflow job for this annotation

GitHub Actions / compile-and-post

Unused '@ts-expect-error' directive.
import castv2 from "castv2-client";
import mdnsjs from "mdns-js";

Expand Down Expand Up @@ -274,7 +275,7 @@ export default class ChromecastPlugin {
this.connectedHosts[device.host] = client;
this.activeConnections.push(client);
}
} catch (e) {}
} catch (e) { }
}
}

Expand Down Expand Up @@ -328,7 +329,7 @@ export default class ChromecastPlugin {
this.activeConnections.forEach((client: any) => {
try {
client.stop();
} catch (e) {}
} catch (e) { }
});
this.activeConnections = [];
this.connectedHosts = {};
Expand All @@ -338,13 +339,13 @@ export default class ChromecastPlugin {
/**
* Runs on app stop
*/
onBeforeQuit(): void {}
onBeforeQuit(): void { }

/**
* Runs on song change
* @param attributes Music Attributes
*/
onNowPlayingItemDidChange(attributes: any): void {}
onNowPlayingItemDidChange(attributes: any): void { }

onRendererReady(): void {
this._win.webContents.executeJavaScript(`ipcRenderer.sendSync('get-port')`).then((result: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/main/plugins/raop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export default class RAOP {
// if (err) throw err;
// console.log('It\'s saved!');
// });
this.airtunes.circularBuffer.write(Buffer.from(Int8Array.from(result.outbuffer)));
this.airtunes.circularBuffer.write(Buffer.from(new Uint8Array(result.outbuffer)));
});

this.worker.on("error", (error: any) => {
Expand Down

0 comments on commit c4c084e

Please sign in to comment.