Skip to content

Commit f929b8a

Browse files
Merge pull request #112 from MegaAntiCheat/megascatterbomb/miscfixes
Miscellanious fixes
2 parents b82af17 + 64640c1 commit f929b8a

File tree

9 files changed

+92
-26
lines changed

9 files changed

+92
-26
lines changed

i18n/en_US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"CLICK_TO_COLLECT_DATA": "Click to collect data",
117117
"NO_DATA": "No data",
118118
"ADD_PLAYER": "Add player",
119-
"ADD_PLAYER_HELP": "If you search for a SteamID that is not in your archive, click this button to add it.",
119+
"ADD_PLAYER_HELP": "If you search for a SteamID that is not in\nyour archive, click this button to add it.",
120120
"SELECT_VERDICT": "Select a verdict...",
121121
"SET_CUSTOM_ALIAS": "Set a custom alias...",
122122
"ADD_CUSTOM_NOTE": "Add additional information...",

public/kiwi_green.webp

26.3 KB
Binary file not shown.

public/kiwi_yellow.webp

27.8 KB
Binary file not shown.

src/Pages/PlayerHistory/PlayerHistory.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Checkbox from '@components/General/Checkbox/Checkbox';
88
import { getSteamID64 } from '@api/steamid';
99
import { useModal } from '../../Context/ModalContext';
1010
import { AddPlayerModal } from '@components/TF2';
11+
import { Tooltip } from '@components/General';
1112

1213
// Maps Steam IDs of each search result to its relevance
1314
export type SearchRelevance = Map<string, string>;
@@ -75,6 +76,7 @@ const PlayerHistory = () => {
7576
const query64 = getSteamID64(query.trim());
7677
const result =
7778
query64 &&
79+
query64 === query &&
7880
![newRecent, newArchive].flat().some((p) => p.steamID64 === query64)
7981
? query64
8082
: undefined;
@@ -96,20 +98,28 @@ const PlayerHistory = () => {
9698
className="ml-4 mt-3 mb-3 w-[calc(100%-350px)]"
9799
onChange={handleSearch}
98100
/>
99-
<button
100-
className={`ml-4 mt-3 mb-3 h-10v w-[100px] rounded-sm items-center ${
101-
playerToAdd ? 'bg-blue-700' : 'bg-gray-400'
102-
}`}
103-
disabled={!playerToAdd}
104-
onClick={() => {
105-
if (!playerToAdd) return;
106-
openModal(<AddPlayerModal steamID64={playerToAdd} />, {
107-
dismissable: true,
108-
});
109-
}}
101+
<Tooltip
102+
direction="bottom-left"
103+
className="items-center"
104+
content={t('ADD_PLAYER_HELP')}
105+
noWrap={true}
106+
isButton={true}
110107
>
111-
{t('ADD_PLAYER')}
112-
</button>
108+
<button
109+
className={`ml-4 mt-3 mb-3 h-15v w-[100px] rounded-sm items-center ${
110+
playerToAdd ? 'bg-blue-700' : 'bg-gray-400'
111+
}`}
112+
disabled={!playerToAdd}
113+
onClick={() => {
114+
if (!playerToAdd) return;
115+
openModal(<AddPlayerModal steamID64={playerToAdd} />, {
116+
dismissable: true,
117+
});
118+
}}
119+
>
120+
{t('ADD_PLAYER')}
121+
</button>
122+
</Tooltip>
113123
<Checkbox
114124
className="case-sensitive-checkbox ml-4 mt-3 mb-3 h-4 items-center"
115125
checked={caseSensitive}

src/api/players/index.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,22 @@ async function fetchPlayerInfos({
7575
}
7676
}
7777

78+
function timeoutPromise(ms: number): Promise<never> {
79+
return new Promise((resolve) => {
80+
setTimeout(() => {
81+
resolve('timeout' as never);
82+
}, ms);
83+
});
84+
}
85+
86+
async function fetchWithTimeout(
87+
url: string,
88+
options: RequestInit,
89+
timeout: number = 5000,
90+
): Promise<Response> {
91+
return Promise.race([fetch(url, options), timeoutPromise(timeout)]);
92+
}
93+
7894
async function updateSteamInfo(steamIDs: string[]): Promise<PlayerInfo[]> {
7995
try {
8096
if (useFakedata) return [];
@@ -87,7 +103,7 @@ async function updateSteamInfo(steamIDs: string[]): Promise<PlayerInfo[]> {
87103
},
88104
};
89105

90-
const response = await fetch(USER_ENDPOINT, options);
106+
const response = await fetchWithTimeout(USER_ENDPOINT, options);
91107

92108
if (!response.ok) throw new Error('Failed to fetch player history');
93109

src/components/General/Tooltip/Tooltip.css

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
}
44

55
.tooltip.left {
6-
76
@apply top-2/4 right-full -translate-y-2/4;
87
}
98

@@ -15,7 +14,22 @@
1514
@apply top-full -translate-x-1/3;
1615
}
1716

17+
.tooltip.bottom-right {
18+
@apply top-full left-0;
19+
}
20+
21+
.tooltip.bottom-left {
22+
@apply top-full right-0;
23+
}
24+
25+
.tooltip.top-left {
26+
@apply bottom-full left-0;
27+
}
28+
29+
.tooltip.top-right {
30+
@apply bottom-full right-0;
31+
}
32+
1833
.tooltip-container:hover .tooltip {
1934
@apply opacity-100;
2035
}
21-

src/components/General/Tooltip/Tooltip.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,48 @@ interface TooltipProps {
55
content: string;
66
className?: string;
77
children?: ReactNode;
8-
direction?: 'top' | 'bottom' | 'left' | 'right';
8+
direction?:
9+
| 'top'
10+
| 'bottom'
11+
| 'left'
12+
| 'right'
13+
| 'bottom-left'
14+
| 'bottom-right'
15+
| 'top-left'
16+
| 'top-right';
17+
noWrap?: boolean;
18+
isButton?: boolean;
919
}
1020

1121
const Tooltip = ({
1222
content,
1323
className = '',
1424
children,
1525
direction = 'top',
26+
noWrap = false,
27+
isButton = false,
1628
}: TooltipProps) => {
1729
const newLineHandledText = content
1830
.split('\n')
1931
.map((str, index) => <p key={index}>{str}</p>);
2032

2133
return (
22-
<div className={`tooltip-container relative inline-block ${className}`}>
23-
<div className="tooltip-content inline-block align-middle">
34+
<div
35+
className={`tooltip-container relative inline-block ${className} ${
36+
isButton ? 'contents' : ''
37+
}`}
38+
>
39+
<div
40+
className={`tooltip-content inline-block align-middle ${
41+
isButton ? 'contents' : ''
42+
}`}
43+
>
2444
{children}
2545
</div>
2646
<div
2747
className={`tooltip absolute p-1 pl-2 pr-2 bg-neutral-900/[98] pointer-events-none text-white text-base z-50 whitespace-nowrap rounded-md opacity-0 ${direction}`}
2848
>
29-
{newLineHandledText}
49+
{noWrap ? content : newLineHandledText}
3050
</div>
3151
</div>
3252
);

src/components/TF2/Player/playerutils.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,10 +407,16 @@ function buildIconListFromArchive(
407407
onClick={(event) => {
408408
event.preventDefault();
409409
setRefreshing(true);
410-
updateSteamInfo([player.steamID64]).then((r) => {
411-
player.steamInfo = r[0].steamInfo;
412-
setRefreshing(false);
413-
});
410+
updateSteamInfo([player.steamID64])
411+
.then((r) => {
412+
if (r) {
413+
player.steamInfo = r[0].steamInfo;
414+
}
415+
setRefreshing(false);
416+
})
417+
.catch(() => {
418+
setRefreshing(false);
419+
});
414420
}}
415421
width={18}
416422
height={18}

src/components/TF2/ScoreboardTable/ScoreboardTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ const ScoreboardTable = ({
151151
<div className="scoreboard-divider lg:[display:block] h-auto bg-highlight/10 w-[1px] mt-0" />
152152
<div>
153153
{renderTeam(RED, 'RED')}
154-
{renderTeam(SPEC, 'SPECTATOR')}
155154
{renderTeam(UNASSIGNED, 'UNASSIGNED')}
155+
{renderTeam(SPEC, 'SPECTATOR')}
156156
</div>
157157
</div>
158158
);

0 commit comments

Comments
 (0)