ci: updating build to support ws url

This commit is contained in:
Chubby Granny Chaser
2025-05-09 20:52:03 +01:00
parent aa18b57ada
commit 6c44cc0cc4
83 changed files with 1810 additions and 3040 deletions

View File

@@ -6,7 +6,7 @@ import type { TrendingGame } from "@types";
const getTrendingGames = async (_event: Electron.IpcMainInvokeEvent) => {
const language = await db
.get<string, string>(levelKeys.language, {
valueEncoding: "utf-8",
valueEncoding: "utf8",
})
.then((language) => language || "en");

View File

@@ -4,13 +4,13 @@ import * as tar from "tar";
import { registerEvent } from "../register-event";
import axios from "axios";
import os from "node:os";
import { app } from "electron";
import path from "node:path";
import { backupsPath } from "@main/constants";
import type { GameShop } from "@types";
import YAML from "yaml";
import { normalizePath } from "@main/helpers";
import { SystemPath } from "@main/services/system-path";
export interface LudusaviBackup {
files: {
@@ -35,7 +35,7 @@ const replaceLudusaviBackupWithCurrentUser = (
drives: Record<string, string>;
};
const currentHomeDir = normalizePath(app.getPath("home"));
const currentHomeDir = normalizePath(SystemPath.getPath("home"));
/* Renaming logic */
if (os.platform() === "win32") {
@@ -84,7 +84,7 @@ const downloadGameArtifact = async (
homeDir: string;
}>(`/profile/games/artifacts/${gameArtifactId}/download`);
const zipLocation = path.join(app.getPath("userData"), objectKey);
const zipLocation = path.join(SystemPath.getPath("userData"), objectKey);
const backupPath = path.join(backupsPath, `${shop}-${objectId}`);
if (fs.existsSync(backupPath)) {

View File

@@ -1,6 +1,6 @@
import { registerEvent } from "../register-event";
import type { Game, GameShop } from "@types";
import type { GameShop } from "@types";
import { steamGamesWorker } from "@main/workers";
import { createGame } from "@main/services/library-sync";
@@ -15,15 +15,14 @@ const addGameToLibrary = async (
title: string
) => {
const gameKey = levelKeys.game(shop, objectId);
const game = await gamesSublevel.get(gameKey);
let game = await gamesSublevel.get(gameKey);
if (game) {
await downloadsSublevel.del(gameKey);
await gamesSublevel.put(gameKey, {
...game,
isDeleted: false,
});
game.isDeleted = false;
await gamesSublevel.put(gameKey, game);
} else {
const steamGame = await steamGamesWorker.run(Number(objectId), {
name: "getById",
@@ -33,7 +32,7 @@ const addGameToLibrary = async (
? steamUrlBuilder.icon(objectId, steamGame.clientIcon)
: null;
const game: Game = {
game = {
title,
iconUrl,
objectId,
@@ -44,12 +43,12 @@ const addGameToLibrary = async (
lastTimePlayed: null,
};
await gamesSublevel.put(levelKeys.game(shop, objectId), game);
await createGame(game).catch(() => {});
updateLocalUnlockedAchievements(game);
await gamesSublevel.put(gameKey, game);
}
await createGame(game).catch(() => {});
updateLocalUnlockedAchievements(game);
};
registerEvent("addGameToLibrary", addGameToLibrary);

View File

@@ -3,13 +3,16 @@ import createDesktopShortcut from "create-desktop-shortcuts";
import path from "node:path";
import { app } from "electron";
import { removeSymbolsFromName } from "@shared";
import { GameShop } from "@types";
import { GameShop, ShortcutLocation } from "@types";
import { gamesSublevel, levelKeys } from "@main/level";
import { SystemPath } from "@main/services/system-path";
import { windowsStartMenuPath } from "@main/constants";
const createGameShortcut = async (
_event: Electron.IpcMainInvokeEvent,
shop: GameShop,
objectId: string
objectId: string,
location: ShortcutLocation
): Promise<boolean> => {
const gameKey = levelKeys.game(shop, objectId);
const game = await gamesSublevel.get(gameKey);
@@ -24,7 +27,10 @@ const createGameShortcut = async (
const options = {
filePath,
name: removeSymbolsFromName(game.title),
outputPath: app.getPath("desktop"),
outputPath:
location === "desktop"
? SystemPath.getPath("desktop")
: windowsStartMenuPath,
};
return createDesktopShortcut({

View File

@@ -6,7 +6,7 @@ import { db, levelKeys } from "@main/level";
const getBadges = async (_event: Electron.IpcMainInvokeEvent) => {
const language = await db
.get<string, string>(levelKeys.language, {
valueEncoding: "utf-8",
valueEncoding: "utf8",
})
.then((language) => language || "en");

View File

@@ -1,4 +1,3 @@
import { MAIN_LOOP_INTERVAL } from "@main/constants";
import { registerEvent } from "../register-event";
import { HydraApi, WindowManager } from "@main/services";
import { publishNewFriendRequestNotification } from "@main/services/notifications";
@@ -10,14 +9,12 @@ interface SyncState {
tick: number;
}
const ticksToUpdate = (2 * 60 * 1000) / MAIN_LOOP_INTERVAL; // 2 minutes
const syncState: SyncState = {
friendRequestCount: null,
tick: 0,
};
const syncFriendRequests = async () => {
export const syncFriendRequests = async () => {
return HydraApi.get<FriendRequestSync>(`/profile/friend-requests/sync`)
.then((res) => {
if (
@@ -44,16 +41,4 @@ const syncFriendRequests = async () => {
});
};
const syncFriendRequestsEvent = async (_event: Electron.IpcMainInvokeEvent) => {
return syncFriendRequests();
};
export const watchFriendRequests = async () => {
if (syncState.tick % ticksToUpdate === 0) {
await syncFriendRequests();
}
syncState.tick++;
};
registerEvent("syncFriendRequests", syncFriendRequestsEvent);
registerEvent("syncFriendRequests", syncFriendRequests);

View File

@@ -40,7 +40,7 @@ const startGameDownload = async (
/* Delete any previous download */
await downloadsSublevel.del(gameKey);
if (game?.isDeleted) {
if (game) {
await gamesSublevel.put(gameKey, {
...game,
isDeleted: false,

View File

@@ -1,19 +1,8 @@
import { registerEvent } from "../register-event";
import AutoLaunch from "auto-launch";
import { app } from "electron";
import path from "path";
import fs from "node:fs";
import { logger } from "@main/services";
const windowsStartupPath = path.join(
app.getPath("appData"),
"Microsoft",
"Windows",
"Start Menu",
"Programs",
"Startup"
);
const autoLaunch = async (
_event: Electron.IpcMainInvokeEvent,
autoLaunchProps: { enabled: boolean; minimized: boolean }
@@ -30,10 +19,6 @@ const autoLaunch = async (
logger.error(err);
});
} else {
if (process.platform == "win32") {
fs.rm(path.join(windowsStartupPath, "Hydra.vbs"), () => {});
}
appLauncher.disable().catch((err) => {
logger.error(err);
});

View File

@@ -16,7 +16,7 @@ const updateUserPreferences = async (
if (preferences.language) {
await db.put<string, string>(levelKeys.language, preferences.language, {
valueEncoding: "utf-8",
valueEncoding: "utf8",
});
i18next.changeLanguage(preferences.language);