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: [] };
|
||||
|
||||
export const setRepacks = (repacks: GameRepack[]) => {
|
||||
for (let i = 0; i < state.repacks.length; i++) {
|
||||
repacksIndex.remove(i);
|
||||
}
|
||||
|
||||
state.repacks = repacks;
|
||||
|
||||
for (let i = 0; i < repacks.length; i++) {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from "react";
|
|||
import { useTranslation } from "react-i18next";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
|
||||
import type { Game } from "@types";
|
||||
import type { LibraryGame } from "@types";
|
||||
|
||||
import { TextField } from "@renderer/components";
|
||||
import { useDownload, useLibrary } from "@renderer/hooks";
|
||||
|
@ -25,9 +25,7 @@ export function Sidebar() {
|
|||
const { library, updateLibrary } = useLibrary();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [filteredLibrary, setFilteredLibrary] = useState<
|
||||
Omit<Game, "repacks">[]
|
||||
>([]);
|
||||
const [filteredLibrary, setFilteredLibrary] = useState<LibraryGame[]>([]);
|
||||
|
||||
const [isResizing, setIsResizing] = useState(false);
|
||||
const [sidebarWidth, setSidebarWidth] = useState(
|
||||
|
@ -101,7 +99,7 @@ export function Sidebar() {
|
|||
};
|
||||
}, [isResizing]);
|
||||
|
||||
const getGameTitle = (game: Omit<Game, "repacks">) => {
|
||||
const getGameTitle = (game: LibraryGame) => {
|
||||
if (game.status === "paused") return t("paused", { title: game.title });
|
||||
|
||||
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,
|
||||
CatalogueEntry,
|
||||
Game,
|
||||
LibraryGame,
|
||||
GameRepack,
|
||||
GameShop,
|
||||
HowLongToBeatCategory,
|
||||
|
@ -58,7 +59,7 @@ declare global {
|
|||
shop: GameShop,
|
||||
executablePath: string | null
|
||||
) => Promise<void>;
|
||||
getLibrary: () => Promise<Omit<Game, "repacks">[]>;
|
||||
getLibrary: () => Promise<LibraryGame[]>;
|
||||
openGameInstaller: (gameId: number) => Promise<boolean>;
|
||||
openGame: (gameId: number, executablePath: string) => Promise<void>;
|
||||
closeGame: (gameId: number) => Promise<boolean>;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { createSlice } from "@reduxjs/toolkit";
|
||||
import type { PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
import type { Game } from "@types";
|
||||
import type { LibraryGame } from "@types";
|
||||
|
||||
export interface LibraryState {
|
||||
value: Omit<Game, "repacks">[];
|
||||
value: LibraryGame[];
|
||||
}
|
||||
|
||||
const initialState: LibraryState = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import type { CatalogueEntry } from "@types";
|
||||
import type { GameShop } from "@types";
|
||||
|
||||
export const steamUrlBuilder = {
|
||||
library: (objectID: string) =>
|
||||
|
@ -34,7 +34,7 @@ export const getSteamLanguage = (language: string) => {
|
|||
};
|
||||
|
||||
export const buildGameDetailsPath = (
|
||||
game: Pick<CatalogueEntry, "title" | "shop" | "objectID">,
|
||||
game: { shop: GameShop; objectID: string; title: string },
|
||||
params: Record<string, string> = {}
|
||||
) => {
|
||||
const searchParams = new URLSearchParams({ title: game.title, ...params });
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
steamUrlBuilder,
|
||||
} from "@renderer/helpers";
|
||||
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 { BinaryNotFoundModal } from "../shared-modals/binary-not-found-modal";
|
||||
|
@ -30,9 +30,7 @@ export function Downloads() {
|
|||
|
||||
const gameToBeDeleted = useRef<number | null>(null);
|
||||
|
||||
const [filteredLibrary, setFilteredLibrary] = useState<
|
||||
Omit<Game, "repacks">[]
|
||||
>([]);
|
||||
const [filteredLibrary, setFilteredLibrary] = useState<LibraryGame[]>([]);
|
||||
const [showBinaryNotFoundModal, setShowBinaryNotFoundModal] = useState(false);
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||
|
||||
|
@ -61,7 +59,7 @@ export function Downloads() {
|
|||
updateLibrary();
|
||||
});
|
||||
|
||||
const getFinalDownloadSize = (game: Omit<Game, "repacks">) => {
|
||||
const getFinalDownloadSize = (game: LibraryGame) => {
|
||||
const isGameDownloading = lastPacket?.game.id === game.id;
|
||||
|
||||
if (game.fileSize) return formatBytes(game.fileSize);
|
||||
|
@ -72,7 +70,7 @@ export function Downloads() {
|
|||
return "N/A";
|
||||
};
|
||||
|
||||
const getGameInfo = (game: Omit<Game, "repacks">) => {
|
||||
const getGameInfo = (game: LibraryGame) => {
|
||||
const isGameDownloading = lastPacket?.game.id === game.id;
|
||||
const finalDownloadSize = getFinalDownloadSize(game);
|
||||
|
||||
|
@ -132,7 +130,7 @@ export function Downloads() {
|
|||
setShowDeleteModal(true);
|
||||
};
|
||||
|
||||
const getGameActions = (game: Omit<Game, "repacks">) => {
|
||||
const getGameActions = (game: LibraryGame) => {
|
||||
const isGameDownloading = lastPacket?.game.id === game.id;
|
||||
|
||||
const deleting = isGameDeleting(game.id);
|
||||
|
|
|
@ -87,7 +87,7 @@ export interface CatalogueEntry {
|
|||
}
|
||||
|
||||
/* Used by the library */
|
||||
export interface Game extends Omit<CatalogueEntry, "cover"> {
|
||||
export interface Game {
|
||||
id: number;
|
||||
title: string;
|
||||
iconUrl: string;
|
||||
|
@ -102,17 +102,21 @@ export interface Game extends Omit<CatalogueEntry, "cover"> {
|
|||
executablePath: string | null;
|
||||
lastTimePlayed: Date | null;
|
||||
fileSize: number;
|
||||
objectID: string;
|
||||
shop: GameShop;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export type LibraryGame = Omit<Game, "repacks">;
|
||||
|
||||
export interface DownloadProgress {
|
||||
downloadSpeed: number;
|
||||
timeRemaining: number;
|
||||
numPeers: number;
|
||||
numSeeds: number;
|
||||
isDownloadingMetadata: boolean;
|
||||
game: Omit<Game, "repacks">;
|
||||
game: LibraryGame;
|
||||
}
|
||||
|
||||
export interface UserPreferences {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue