mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
fix: removing all indices from flexsearch index
This commit is contained in:
parent
4b1248b865
commit
467ea29ec2
7 changed files with 24 additions and 19 deletions
|
@ -7,6 +7,10 @@ const repacksIndex = new flexSearch.Index();
|
||||||
const state: { repacks: GameRepack[] } = { repacks: [] };
|
const state: { repacks: GameRepack[] } = { repacks: [] };
|
||||||
|
|
||||||
export const setRepacks = (repacks: GameRepack[]) => {
|
export const setRepacks = (repacks: GameRepack[]) => {
|
||||||
|
for (let i = 0; i < state.repacks.length; i++) {
|
||||||
|
repacksIndex.remove(i);
|
||||||
|
}
|
||||||
|
|
||||||
state.repacks = repacks;
|
state.repacks = repacks;
|
||||||
|
|
||||||
for (let i = 0; i < repacks.length; i++) {
|
for (let i = 0; i < repacks.length; i++) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useLocation, useNavigate } from "react-router-dom";
|
import { useLocation, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import type { Game } from "@types";
|
import type { LibraryGame } from "@types";
|
||||||
|
|
||||||
import { TextField } from "@renderer/components";
|
import { TextField } from "@renderer/components";
|
||||||
import { useDownload, useLibrary } from "@renderer/hooks";
|
import { useDownload, useLibrary } from "@renderer/hooks";
|
||||||
|
@ -25,9 +25,7 @@ export function Sidebar() {
|
||||||
const { library, updateLibrary } = useLibrary();
|
const { library, updateLibrary } = useLibrary();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [filteredLibrary, setFilteredLibrary] = useState<
|
const [filteredLibrary, setFilteredLibrary] = useState<LibraryGame[]>([]);
|
||||||
Omit<Game, "repacks">[]
|
|
||||||
>([]);
|
|
||||||
|
|
||||||
const [isResizing, setIsResizing] = useState(false);
|
const [isResizing, setIsResizing] = useState(false);
|
||||||
const [sidebarWidth, setSidebarWidth] = useState(
|
const [sidebarWidth, setSidebarWidth] = useState(
|
||||||
|
@ -101,7 +99,7 @@ export function Sidebar() {
|
||||||
};
|
};
|
||||||
}, [isResizing]);
|
}, [isResizing]);
|
||||||
|
|
||||||
const getGameTitle = (game: Omit<Game, "repacks">) => {
|
const getGameTitle = (game: LibraryGame) => {
|
||||||
if (game.status === "paused") return t("paused", { title: game.title });
|
if (game.status === "paused") return t("paused", { title: game.title });
|
||||||
|
|
||||||
if (lastPacket?.game.id === game.id) {
|
if (lastPacket?.game.id === game.id) {
|
||||||
|
|
3
src/renderer/src/declaration.d.ts
vendored
3
src/renderer/src/declaration.d.ts
vendored
|
@ -2,6 +2,7 @@ import type {
|
||||||
AppUpdaterEvents,
|
AppUpdaterEvents,
|
||||||
CatalogueEntry,
|
CatalogueEntry,
|
||||||
Game,
|
Game,
|
||||||
|
LibraryGame,
|
||||||
GameRepack,
|
GameRepack,
|
||||||
GameShop,
|
GameShop,
|
||||||
HowLongToBeatCategory,
|
HowLongToBeatCategory,
|
||||||
|
@ -58,7 +59,7 @@ declare global {
|
||||||
shop: GameShop,
|
shop: GameShop,
|
||||||
executablePath: string | null
|
executablePath: string | null
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
getLibrary: () => Promise<Omit<Game, "repacks">[]>;
|
getLibrary: () => Promise<LibraryGame[]>;
|
||||||
openGameInstaller: (gameId: number) => Promise<boolean>;
|
openGameInstaller: (gameId: number) => Promise<boolean>;
|
||||||
openGame: (gameId: number, executablePath: string) => Promise<void>;
|
openGame: (gameId: number, executablePath: string) => Promise<void>;
|
||||||
closeGame: (gameId: number) => Promise<boolean>;
|
closeGame: (gameId: number) => Promise<boolean>;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { createSlice } from "@reduxjs/toolkit";
|
import { createSlice } from "@reduxjs/toolkit";
|
||||||
import type { PayloadAction } from "@reduxjs/toolkit";
|
import type { PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
|
||||||
import type { Game } from "@types";
|
import type { LibraryGame } from "@types";
|
||||||
|
|
||||||
export interface LibraryState {
|
export interface LibraryState {
|
||||||
value: Omit<Game, "repacks">[];
|
value: LibraryGame[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: LibraryState = {
|
const initialState: LibraryState = {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { CatalogueEntry } from "@types";
|
import type { GameShop } from "@types";
|
||||||
|
|
||||||
export const steamUrlBuilder = {
|
export const steamUrlBuilder = {
|
||||||
library: (objectID: string) =>
|
library: (objectID: string) =>
|
||||||
|
@ -34,7 +34,7 @@ export const getSteamLanguage = (language: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const buildGameDetailsPath = (
|
export const buildGameDetailsPath = (
|
||||||
game: Pick<CatalogueEntry, "title" | "shop" | "objectID">,
|
game: { shop: GameShop; objectID: string; title: string },
|
||||||
params: Record<string, string> = {}
|
params: Record<string, string> = {}
|
||||||
) => {
|
) => {
|
||||||
const searchParams = new URLSearchParams({ title: game.title, ...params });
|
const searchParams = new URLSearchParams({ title: game.title, ...params });
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {
|
||||||
steamUrlBuilder,
|
steamUrlBuilder,
|
||||||
} from "@renderer/helpers";
|
} from "@renderer/helpers";
|
||||||
import { useAppSelector, useDownload, useLibrary } from "@renderer/hooks";
|
import { useAppSelector, useDownload, useLibrary } from "@renderer/hooks";
|
||||||
import type { Game } from "@types";
|
import type { LibraryGame } from "@types";
|
||||||
|
|
||||||
import { useEffect, useMemo, useRef, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal";
|
import { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal";
|
||||||
|
@ -30,9 +30,7 @@ export function Downloads() {
|
||||||
|
|
||||||
const gameToBeDeleted = useRef<number | null>(null);
|
const gameToBeDeleted = useRef<number | null>(null);
|
||||||
|
|
||||||
const [filteredLibrary, setFilteredLibrary] = useState<
|
const [filteredLibrary, setFilteredLibrary] = useState<LibraryGame[]>([]);
|
||||||
Omit<Game, "repacks">[]
|
|
||||||
>([]);
|
|
||||||
const [showBinaryNotFoundModal, setShowBinaryNotFoundModal] = useState(false);
|
const [showBinaryNotFoundModal, setShowBinaryNotFoundModal] = useState(false);
|
||||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||||
|
|
||||||
|
@ -61,7 +59,7 @@ export function Downloads() {
|
||||||
updateLibrary();
|
updateLibrary();
|
||||||
});
|
});
|
||||||
|
|
||||||
const getFinalDownloadSize = (game: Omit<Game, "repacks">) => {
|
const getFinalDownloadSize = (game: LibraryGame) => {
|
||||||
const isGameDownloading = lastPacket?.game.id === game.id;
|
const isGameDownloading = lastPacket?.game.id === game.id;
|
||||||
|
|
||||||
if (game.fileSize) return formatBytes(game.fileSize);
|
if (game.fileSize) return formatBytes(game.fileSize);
|
||||||
|
@ -72,7 +70,7 @@ export function Downloads() {
|
||||||
return "N/A";
|
return "N/A";
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGameInfo = (game: Omit<Game, "repacks">) => {
|
const getGameInfo = (game: LibraryGame) => {
|
||||||
const isGameDownloading = lastPacket?.game.id === game.id;
|
const isGameDownloading = lastPacket?.game.id === game.id;
|
||||||
const finalDownloadSize = getFinalDownloadSize(game);
|
const finalDownloadSize = getFinalDownloadSize(game);
|
||||||
|
|
||||||
|
@ -132,7 +130,7 @@ export function Downloads() {
|
||||||
setShowDeleteModal(true);
|
setShowDeleteModal(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getGameActions = (game: Omit<Game, "repacks">) => {
|
const getGameActions = (game: LibraryGame) => {
|
||||||
const isGameDownloading = lastPacket?.game.id === game.id;
|
const isGameDownloading = lastPacket?.game.id === game.id;
|
||||||
|
|
||||||
const deleting = isGameDeleting(game.id);
|
const deleting = isGameDeleting(game.id);
|
||||||
|
|
|
@ -87,7 +87,7 @@ export interface CatalogueEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used by the library */
|
/* Used by the library */
|
||||||
export interface Game extends Omit<CatalogueEntry, "cover"> {
|
export interface Game {
|
||||||
id: number;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
iconUrl: string;
|
iconUrl: string;
|
||||||
|
@ -102,17 +102,21 @@ export interface Game extends Omit<CatalogueEntry, "cover"> {
|
||||||
executablePath: string | null;
|
executablePath: string | null;
|
||||||
lastTimePlayed: Date | null;
|
lastTimePlayed: Date | null;
|
||||||
fileSize: number;
|
fileSize: number;
|
||||||
|
objectID: string;
|
||||||
|
shop: GameShop;
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
updatedAt: Date;
|
updatedAt: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type LibraryGame = Omit<Game, "repacks">;
|
||||||
|
|
||||||
export interface DownloadProgress {
|
export interface DownloadProgress {
|
||||||
downloadSpeed: number;
|
downloadSpeed: number;
|
||||||
timeRemaining: number;
|
timeRemaining: number;
|
||||||
numPeers: number;
|
numPeers: number;
|
||||||
numSeeds: number;
|
numSeeds: number;
|
||||||
isDownloadingMetadata: boolean;
|
isDownloadingMetadata: boolean;
|
||||||
game: Omit<Game, "repacks">;
|
game: LibraryGame;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserPreferences {
|
export interface UserPreferences {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue