mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
update playlist
This commit is contained in:
1 parent
7630cc52d3
commit
36e8a20cd5
5 files changed
+23
-23
No files matched your search
@@ -12,7 +12,7 @@ import {
|
|||||||
} from "@radix-ui/themes";
|
} from "@radix-ui/themes";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import usePromise from "react-promise-suspense";
|
import usePromise from "react-promise-suspense";
|
||||||
import { awaitableTankDefinitions } from "../core/awaitables/tankDefinitions";
|
import { api } from "../core/blitzkit/api";
|
||||||
import { filterTanks } from "../core/blitzkit/filterTanks";
|
import { filterTanks } from "../core/blitzkit/filterTanks";
|
||||||
import { generatePlaylist } from "../core/blitzkit/generatePlaylist";
|
import { generatePlaylist } from "../core/blitzkit/generatePlaylist";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../hooks/useLocale";
|
||||||
@@ -22,7 +22,7 @@ import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponen
|
|||||||
import { LinkI18n } from "./LinkI18n";
|
import { LinkI18n } from "./LinkI18n";
|
||||||
import { FilterControl } from "./TankSearch/components/FilterControl";
|
import { FilterControl } from "./TankSearch/components/FilterControl";
|
||||||
|
|
||||||
const tankDefinitions = await awaitableTankDefinitions;
|
const tankDefinitions = await api.tankDefinitions();
|
||||||
|
|
||||||
const POOL_HEIGHT = "16rem";
|
const POOL_HEIGHT = "16rem";
|
||||||
|
|
||||||
@@ -33,12 +33,12 @@ export function PlaylistGenerator({ skeleton }: MaybeSkeletonComponentProps) {
|
|||||||
const filters = TankFilters.use();
|
const filters = TankFilters.use();
|
||||||
const randomTankList = useMemo(
|
const randomTankList = useMemo(
|
||||||
() => fisherYates(Object.values(tankDefinitions.tanks)),
|
() => fisherYates(Object.values(tankDefinitions.tanks)),
|
||||||
[filters]
|
[filters],
|
||||||
);
|
);
|
||||||
const tanks = usePromise(
|
const tanks = usePromise(
|
||||||
() => filterTanks(filters, randomTankList, wargaming?.id),
|
() => filterTanks(filters, randomTankList, wargaming?.id),
|
||||||
// react-promise-suspense has awful type annotations
|
// react-promise-suspense has awful type annotations
|
||||||
[filters] as any
|
[filters] as any,
|
||||||
);
|
);
|
||||||
const tanksTrimmed = useMemo(() => tanks.slice(0, 65), [filters]);
|
const tanksTrimmed = useMemo(() => tanks.slice(0, 65), [filters]);
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ export function PlaylistGenerator({ skeleton }: MaybeSkeletonComponentProps) {
|
|||||||
{
|
{
|
||||||
count: tanks.length,
|
count: tanks.length,
|
||||||
time: Math.round(tanks.length * ((2 * 4) / 60)),
|
time: Math.round(tanks.length * ((2 * 4) / 60)),
|
||||||
}
|
},
|
||||||
)}
|
)}
|
||||||
</AlertDialog.Description>
|
</AlertDialog.Description>
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ export function PlaylistGenerator({ skeleton }: MaybeSkeletonComponentProps) {
|
|||||||
backgroundRepeat: "no-repeat",
|
backgroundRepeat: "no-repeat",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)
|
),
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
} from "@radix-ui/react-icons";
|
} from "@radix-ui/react-icons";
|
||||||
import { Checkbox, Flex, IconButton, Table, Text } from "@radix-ui/themes";
|
import { Checkbox, Flex, IconButton, Table, Text } from "@radix-ui/themes";
|
||||||
import { memo } from "react";
|
import { memo } from "react";
|
||||||
import { awaitableTankDefinitions } from "../core/awaitables/tankDefinitions";
|
import { api } from "../core/blitzkit/api";
|
||||||
import { useLocale } from "../hooks/useLocale";
|
import { useLocale } from "../hooks/useLocale";
|
||||||
import { Playlist, type PlaylistEntry } from "../stores/playlist";
|
import { Playlist, type PlaylistEntry } from "../stores/playlist";
|
||||||
import { TankRowHeaderCell } from "./TankRowHeaderCell";
|
import { TankRowHeaderCell } from "./TankRowHeaderCell";
|
||||||
@@ -14,7 +14,7 @@ interface Props extends PlaylistEntry {
|
|||||||
index: number;
|
index: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const tankDefinitions = await awaitableTankDefinitions;
|
const tankDefinitions = await api.tankDefinitions();
|
||||||
|
|
||||||
export const PlaylistTankEntry = memo<Props>(
|
export const PlaylistTankEntry = memo<Props>(
|
||||||
({ id, checked, then, now, index }) => {
|
({ id, checked, then, now, index }) => {
|
||||||
@@ -93,7 +93,7 @@ export const PlaylistTankEntry = memo<Props>(
|
|||||||
{now && now.last !== 0
|
{now && now.last !== 0
|
||||||
? rtf.format(
|
? rtf.format(
|
||||||
Math.ceil((now.last - dateNow / 1000) / (60 * 60 * 24)),
|
Math.ceil((now.last - dateNow / 1000) / (60 * 60 * 24)),
|
||||||
"day"
|
"day",
|
||||||
)
|
)
|
||||||
: strings.website.tools.playlist.table.unrecorded}
|
: strings.website.tools.playlist.table.unrecorded}
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
@@ -103,5 +103,5 @@ export const PlaylistTankEntry = memo<Props>(
|
|||||||
(a, b) =>
|
(a, b) =>
|
||||||
a.checked === b.checked &&
|
a.checked === b.checked &&
|
||||||
a.then?.battles === b.then?.battles &&
|
a.then?.battles === b.then?.battles &&
|
||||||
a.index === b.index
|
a.index === b.index,
|
||||||
);
|
);
|
||||||
@@ -7,10 +7,10 @@ import {
|
|||||||
import { App } from "../../stores/app";
|
import { App } from "../../stores/app";
|
||||||
import { Playlist } from "../../stores/playlist";
|
import { Playlist } from "../../stores/playlist";
|
||||||
import { TankFilters } from "../../stores/tankFilters";
|
import { TankFilters } from "../../stores/tankFilters";
|
||||||
import { awaitableTankDefinitions } from "../awaitables/tankDefinitions";
|
import { api } from "./api";
|
||||||
import { filterTanks } from "./filterTanks";
|
import { filterTanks } from "./filterTanks";
|
||||||
|
|
||||||
const tankDefinitions = await awaitableTankDefinitions;
|
const tankDefinitions = await api.tankDefinitions();
|
||||||
const tanks = Object.values(tankDefinitions.tanks);
|
const tanks = Object.values(tankDefinitions.tanks);
|
||||||
|
|
||||||
export async function generatePlaylist() {
|
export async function generatePlaylist() {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { PageWrapper } from "../../../components/PageWrapper";
|
import { PageWrapper } from "../../../../components/PageWrapper";
|
||||||
import { PlaylistGenerator } from "../../../components/PlaylistGenerator";
|
import { PlaylistGenerator } from "../../../../components/PlaylistGenerator";
|
||||||
import { PlaylistOrder } from "../../../components/PlaylistOrder";
|
import { PlaylistOrder } from "../../../../components/PlaylistOrder";
|
||||||
import { LocaleProvider } from "../../../hooks/useLocale";
|
import { LocaleProvider } from "../../../../hooks/useLocale";
|
||||||
import { App } from "../../../stores/app";
|
import { App } from "../../../../stores/app";
|
||||||
import { Playlist } from "../../../stores/playlist";
|
import { Playlist } from "../../../../stores/playlist";
|
||||||
import { TankFilters } from "../../../stores/tankFilters";
|
import { TankFilters } from "../../../../stores/tankFilters";
|
||||||
import type { MaybeSkeletonComponentProps } from "../../../types/maybeSkeletonComponentProps";
|
import type { MaybeSkeletonComponentProps } from "../../../../types/maybeSkeletonComponentProps";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
locale: string;
|
locale: string;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
import ToolOpenGraph from "../../../components/ToolOpenGraph.astro";
|
import ToolOpenGraph from "../../../../components/ToolOpenGraph.astro";
|
||||||
import { tools } from "../../../constants/tools";
|
import { tools } from "../../../../constants/tools";
|
||||||
import BaseLayout from "../../../layouts/BaseLayout.astro";
|
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
||||||
import { Page } from "./_index.tsx";
|
import { Page } from "./_index.tsx";
|
||||||
|
|
||||||
export { getStaticPaths } from "../index.astro";
|
export { getStaticPaths } from "../index.astro";
|
||||||
|
|||||||
Reference in new issue
Block a user