mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: deleted user handling
This commit is contained in:
1 parent
57527115d4
commit
0b9db21c10
2 files changed
+19
-7
No files matched your search
@@ -29,7 +29,9 @@ import { noArrows } from './page.css';
|
|||||||
|
|
||||||
const ROWS_OPTIONS = [5, 10, 25, 50, 100];
|
const ROWS_OPTIONS = [5, 10, 25, 50, 100];
|
||||||
|
|
||||||
const useUsernameCache = create<Record<Region, Record<number, string>>>(() => ({
|
type UsernameCache = Record<Region, Record<number, string | null>>;
|
||||||
|
|
||||||
|
const useUsernameCache = create<UsernameCache>(() => ({
|
||||||
asia: {},
|
asia: {},
|
||||||
com: {},
|
com: {},
|
||||||
eu: {},
|
eu: {},
|
||||||
@@ -124,10 +126,14 @@ export default function Page() {
|
|||||||
|
|
||||||
if (ids && ids.length > 0) {
|
if (ids && ids.length > 0) {
|
||||||
getAccountInfo(region, ids).then((data) => {
|
getAccountInfo(region, ids).then((data) => {
|
||||||
data.map((player) => {
|
data.map((player, index) => {
|
||||||
useUsernameCache.setState(
|
useUsernameCache.setState(
|
||||||
produce((draft) => {
|
produce((draft: UsernameCache) => {
|
||||||
draft[region][player.account_id] = player.nickname;
|
if (player) {
|
||||||
|
draft[region][ids[index]] = player.nickname;
|
||||||
|
} else {
|
||||||
|
draft[region][ids[index]] = null;
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -432,8 +438,11 @@ export default function Page() {
|
|||||||
playerSlice?.map((player, index) => (
|
playerSlice?.map((player, index) => (
|
||||||
<Leaderboard.Item
|
<Leaderboard.Item
|
||||||
nickname={
|
nickname={
|
||||||
usernameCache[region][player.id] ??
|
usernameCache[region][player.id] === null
|
||||||
`Loading player ${player.id}...`
|
? `Deleted player ${player.id}`
|
||||||
|
: usernameCache[region][player.id]
|
||||||
|
? usernameCache[region][player.id]!
|
||||||
|
: `Loading player ${player.id}...`
|
||||||
}
|
}
|
||||||
position={page * rowsPerPage + index + 1}
|
position={page * rowsPerPage + index + 1}
|
||||||
score={player.score}
|
score={player.score}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
import { ComponentProps } from 'react';
|
||||||
import { RatingsReward } from '../../../commands/ratings';
|
import { RatingsReward } from '../../../commands/ratings';
|
||||||
import { theme } from '../../../stitches.config';
|
import { theme } from '../../../stitches.config';
|
||||||
|
|
||||||
export interface ItemProps {
|
export interface ItemProps extends ComponentProps<'div'> {
|
||||||
position: number;
|
position: number;
|
||||||
deltaPosition?: number;
|
deltaPosition?: number;
|
||||||
score: number;
|
score: number;
|
||||||
@@ -25,9 +26,11 @@ export function Item({
|
|||||||
nickname,
|
nickname,
|
||||||
clan,
|
clan,
|
||||||
highlight,
|
highlight,
|
||||||
|
...props
|
||||||
}: ItemProps) {
|
}: ItemProps) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
{...props}
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
padding: 8,
|
padding: 8,
|
||||||
|
|||||||
Reference in new issue
Block a user