Skip to content

Commit

Permalink
add go to project button for external projects
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Oct 26, 2023
1 parent 83ad5eb commit 876bce1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/api/GametoolsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export class ApiProvider extends JsonClient {
if (game == "bf1marne") {
return await bf1MarneApi.serverList({ searchTerm, regions, limit });
}
return await this.getJsonMethod(`/${gameStuff[0]}/servers/`, {
const result = await this.getJsonMethod(`/${gameStuff[0]}/servers/`, {
name: encodeURIComponent(serverName),
experiencename: encodeURIComponent(experienceName),
lang: lang,
Expand All @@ -415,6 +415,11 @@ export class ApiProvider extends JsonClient {
limit: limit,
...extraQueries,
});
// hard limit to 4 on main page
if (limit === "4") {
result.servers = result.servers.slice(0, 4);
}
return result;
}

async graphs({
Expand Down
9 changes: 9 additions & 0 deletions src/api/static.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ export const supportedGames = [
"battlebit",
];

export const projects = {
"bfvietnam.openspy": "http://openspy.net",
"bf2.bf2hub": "https://www.bf2hub.com/",
"bf2.playbf2": "https://playbf2.tilda.ws/en",
"bf2142.openspy": "http://openspy.net",
"bf2142.play2142": "https://battlefield2142.co/",
bf1marne: "https://marne.io/",
};

export const platformGames = {
pc: ["bf3", "bf4", "bfh", "bf1", "bfv", "bf2042"],
xboxone: ["bf4", "bfh", "bf1", "bfv", "bf2042"],
Expand Down
8 changes: 8 additions & 0 deletions src/components/routes/Servers/Search/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
newGen,
newTitles,
oldJoinGames,
projects,
supportedGames,
} from "../../../../api/static";
import { Results } from "./Results";
Expand Down Expand Up @@ -1087,6 +1088,13 @@ export function ServerSearch(): React.ReactElement {
{t("serverSearch.showMore")}
</BigButtonSecondaryBox>
</Link>
{Object.keys(projects).includes(gameName) && (
<a href={projects[gameName]} target="_blank" rel="noreferrer">
<BigButtonSecondaryBox>
{t("serverSearch.showProject")}
</BigButtonSecondaryBox>
</a>
)}
</>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/languages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
"playground": "Experience name"
},
"showMore": "Show more",
"showProject": "Go to project",
"region": "Region",
"map": "Map",
"platform": "platform",
Expand Down

0 comments on commit 876bce1

Please sign in to comment.