Skip to content

Commit

Permalink
dont show as if its endelessly loading when no servers are available
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Nov 18, 2023
1 parent b2c40e2 commit 6944aa5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 33 deletions.
69 changes: 37 additions & 32 deletions src/api/marneApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,38 +273,43 @@ export class ApiProvider extends JsonClient {
this.serverCacheAge = Date.now();
}
const country = await getCurrentCountry();
const servers = this.serverCache.servers
.map((server) => {
const internalMapName: string = server?.mapName
?.split("/")
.slice(-1)[0];
return {
gameId: server?.id.toString(),
prefix: server?.name,
currentMap: maps[internalMapName],
currentMapImage: map_image[internalMapName],
url: map_image[internalMapName],
inQue: 0,
mode: modes[server?.gameMode],
official: false,
ownerId: 0,
region: server?.region,
country: getName(server?.country, country),
platform: "pc",
playerAmount: server?.currentPlayers,
maxPlayerAmount: server?.maxPlayers,
serverInfo: "",
smallMode: smallmodes[server?.gameMode],
};
})
.filter((server) => {
return (
server.prefix.toLowerCase().includes(searchTerm.toLowerCase()) &&
(regions.includes(server.region.toLowerCase()) ||
regions.includes("all"))
);
})
.slice(0, !Number.isNaN(Number(limit)) ? Number(limit) : 10);
const servers =
this.serverCache.servers == undefined
? []
: this.serverCache.servers
.map((server) => {
const internalMapName: string = server?.mapName
?.split("/")
.slice(-1)[0];
return {
gameId: server?.id.toString(),
prefix: server?.name,
currentMap: maps[internalMapName],
currentMapImage: map_image[internalMapName],
url: map_image[internalMapName],
inQue: 0,
mode: modes[server?.gameMode],
official: false,
ownerId: 0,
region: server?.region,
country: getName(server?.country, country),
platform: "pc",
playerAmount: server?.currentPlayers,
maxPlayerAmount: server?.maxPlayers,
serverInfo: "",
smallMode: smallmodes[server?.gameMode],
};
})
.filter((server) => {
return (
server.prefix
.toLowerCase()
.includes(searchTerm.toLowerCase()) &&
(regions.includes(server.region.toLowerCase()) ||
regions.includes("all"))
);
})
.slice(0, !Number.isNaN(Number(limit)) ? Number(limit) : 10);
return {
cache: false,
servers,
Expand Down
1 change: 0 additions & 1 deletion src/components/routes/Servers/Search/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export function Results(props: Views): React.ReactElement {
if (queue !== undefined && queue !== 0 && queue !== null) {
queueString = `[${queue}]`;
}
// console.log(`${t(`regions.${key.region.toLowerCase()}`)}`);
let region: string = undefined;
if (props.game === "bf2042") {
if (Object.keys(regionToTranslation).includes(key.region)) {
Expand Down

0 comments on commit 6944aa5

Please sign in to comment.