Skip to content

Commit

Permalink
Updating config name checking for settings. Obfuscation broke name ma…
Browse files Browse the repository at this point in the history
…tching so object matching is needed. fixes #709
  • Loading branch information
bpatrik committed Sep 2, 2023
1 parent 569b11b commit b8ed84b
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/frontend/app/ui/settings/template/CustomSettingsEntries.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
import {propertyTypes} from 'typeconfig/common';
import {ClientGroupingConfig, ClientSortingConfig, SVGIconConfig} from '../../../../../common/config/public/ClientConfig';

/**
* Configuration in these class have a custom UI
*/
export class CustomSettingsEntries {
public static readonly entries = ['ClientSortingConfig', 'ClientGroupingConfig', 'SVGIconConfig'];
public static readonly entries = [
{c: ClientSortingConfig, name: 'ClientSortingConfig'},
{c: ClientGroupingConfig, name: 'ClientGroupingConfig'},
{c: SVGIconConfig, name: 'SVGIconConfig'},
];

public static getConfigName(s: { tags?: { uiType?: string }, type?: propertyTypes, arrayType?: propertyTypes }): string {
let c = s.tags?.uiType;
try {
if (!c) {
if (s.arrayType) {
c = Object.getPrototypeOf(Object.getPrototypeOf(s?.arrayType))?.name;
} else {
c = Object.getPrototypeOf(Object.getPrototypeOf(s?.type))?.name;
const ent = this.entries.find(e => {
try {
if (s?.arrayType) {
return s?.arrayType == e.c;
}
} catch (e) {
// do nothing
}
if (s?.type) {
return s?.type == e.c;
}
return false;
});
if (ent) {
c = ent.name;
}
}
} catch (e) {
Expand All @@ -32,7 +48,7 @@ export class CustomSettingsEntries {

public static iS(s: { tags?: { uiType?: string }, type?: propertyTypes }) {
const c = this.getConfigName(s);
return this.entries.includes(c);
return this.entries.findIndex(e => e.name == c) !== -1;
}
}

0 comments on commit b8ed84b

Please sign in to comment.