Skip to content

Commit

Permalink
Merge Convars filtering refactor in cfx-ui (pr-2896)
Browse files Browse the repository at this point in the history
7acf258 - tweak(cfx/nui): optimize convar filtering with Set lookup
793d90b - tweak(cfx/nui): hide new convar `sv_replaceExeToSwitchBuilds`
  • Loading branch information
prikolium-cfx committed Nov 5, 2024
2 parents 65f927d + 7acf258 commit 441c7f5
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ext/cfx-ui/src/cfx/common/services/servers/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import {
ServerViewDetailsLevel,
} from './types';

// Add new convars to hide here. All sv_* convars filtered out by default.
const convarsToHide = new Set([
'mapname',
'onesync',
'gametype',
]);

export function serverAddress2ServerView(address: string): IServerView {
const fakeHostname = `⚠️ Server is loading or failed to load (${address}) ⚠️`;

Expand Down Expand Up @@ -187,6 +194,10 @@ function getSortableName(searchableName: string): string {
.toLowerCase();
}

function shouldVarBeShown(key: string): boolean {
return !convarsToHide.has(key) && !key.startsWith('sv_');
}

type VarsView = Partial<
Pick<
IServerView,
Expand Down Expand Up @@ -294,21 +305,11 @@ export function processServerDataVariables(vars?: IServer['data']['vars']): Vars
}
case key === 'sv_pureLevel': {
view.pureLevel = value as ServerPureLevel;

continue;
}

case key === 'sv_poolSizesIncrease':
case key === 'sv_disableClientReplays':
case key === 'onesync':
case key === 'gametype':
case key === 'mapname':
case key === 'sv_enhancedHostSupport':
case key === 'sv_lan':
case key === 'sv_maxClients': {
case !shouldVarBeShown(key): {
continue;
}

case lckey.includes('banner_'):
case lckey.includes('sv_project'):
case lckey.includes('version'):
Expand Down

0 comments on commit 441c7f5

Please sign in to comment.