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

Commit c4c084e

Browse files
committed
fix: various type and logic errors
1 parent 7c44535 commit c4c084e

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

src/main/base/browserwindow.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ export class BrowserWindow {
884884
if (url.endsWith("/")) url = url.slice(0, -1);
885885
let response = await utils.fetch(`${url}/archive/refs/heads/main.zip`);
886886
let repo = url.split("/").slice(-2).join("/");
887-
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json()) as { id: number};
887+
let apiRepo = await utils.fetch(`https://api.github.com/repos/${repo}`).then((res) => res.json()) as { id: number };
888888
console.debug(`REPO ID: ${apiRepo.id}`);
889889
// extract the files from the first folder in the zip response
890890
let zip = new AdmZip(await response.buffer());
@@ -927,7 +927,7 @@ export class BrowserWindow {
927927
"User-Agent": utils.getWindow().webContents.getUserAgent(),
928928
},
929929
})
930-
.then((res) => res.json()) as { id: number}
930+
.then((res) => res.json()) as { id: number }
931931
console.error(apiRepo);
932932
console.debug(`REPO ID: ${apiRepo.id}`);
933933
// extract the files from the first folder in the zip response
@@ -1206,7 +1206,7 @@ export class BrowserWindow {
12061206

12071207
var inputIndex = 0;
12081208

1209-
for (var index = 0; index < length; ) {
1209+
for (var index = 0; index < length;) {
12101210
result[index++] = leftChannel[inputIndex];
12111211
result[index++] = rightChannel[inputIndex];
12121212
inputIndex++;
@@ -1300,7 +1300,10 @@ export class BrowserWindow {
13001300
//let newaudio = [leftpcm, rightpcm];
13011301
// console.log(newaudio.length);
13021302

1303-
let pcmData = Buffer.from(new Int8Array(interleave16(bitratechange(Int16Array.from(newaudio[0], (x) => convert(x))), bitratechange(Int16Array.from(newaudio[1], (x) => convert(x)))).buffer));
1303+
const pcmData = Buffer.from(new Uint8Array(interleave16(
1304+
bitratechange(Int16Array.from(newaudio[0], (x) => convert(x))),
1305+
bitratechange(Int16Array.from(newaudio[1], (x) => convert(x)))
1306+
).buffer));
13041307

13051308
if (!this.headerSent) {
13061309
console.log("new header");

src/main/base/utils.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,11 @@ export class utils {
118118
*/
119119
static getLocale(language: string, key?: string): string | object {
120120
let i18n: any = {};
121+
121122
if (!this.i18n[language]) {
122-
i18n = this.i18n["en"][0].content;
123+
i18n = this.i18n["en-US"][0].content;
123124
} else {
124-
i18n = this.i18n[language ?? "en"][0].content;
125+
i18n = this.i18n[language ?? "en-US"][0].content;
125126
}
126127

127128
if (key) {

src/main/plugins/chromecast.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import electron from "electron";
22
import os from "os";
3-
import {CiderReceiver} from "../base/castreceiver.js";
3+
import { CiderReceiver } from "../base/castreceiver.js";
44
import MediaRendererClient from "upnp-mediarenderer-client";
55
import request from "request";
6+
// @ts-expect-error
67
import castv2 from "castv2-client";
78
import mdnsjs from "mdns-js";
89

@@ -274,7 +275,7 @@ export default class ChromecastPlugin {
274275
this.connectedHosts[device.host] = client;
275276
this.activeConnections.push(client);
276277
}
277-
} catch (e) {}
278+
} catch (e) { }
278279
}
279280
}
280281

@@ -328,7 +329,7 @@ export default class ChromecastPlugin {
328329
this.activeConnections.forEach((client: any) => {
329330
try {
330331
client.stop();
331-
} catch (e) {}
332+
} catch (e) { }
332333
});
333334
this.activeConnections = [];
334335
this.connectedHosts = {};
@@ -338,13 +339,13 @@ export default class ChromecastPlugin {
338339
/**
339340
* Runs on app stop
340341
*/
341-
onBeforeQuit(): void {}
342+
onBeforeQuit(): void { }
342343

343344
/**
344345
* Runs on song change
345346
* @param attributes Music Attributes
346347
*/
347-
onNowPlayingItemDidChange(attributes: any): void {}
348+
onNowPlayingItemDidChange(attributes: any): void { }
348349

349350
onRendererReady(): void {
350351
this._win.webContents.executeJavaScript(`ipcRenderer.sendSync('get-port')`).then((result: any) => {

src/main/plugins/raop.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ export default class RAOP {
326326
// if (err) throw err;
327327
// console.log('It\'s saved!');
328328
// });
329-
this.airtunes.circularBuffer.write(Buffer.from(Int8Array.from(result.outbuffer)));
329+
this.airtunes.circularBuffer.write(Buffer.from(new Uint8Array(result.outbuffer)));
330330
});
331331

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

0 commit comments

Comments
 (0)