1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00

Updating config name checking for settings. Obfuscation broke name matching so object matching is needed. fixes #709

This commit is contained in:
Patrik J. Braun 2023-09-02 15:48:28 +02:00
parent 569b11b1b1
commit b8ed84b7ae

View File

@ -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) {
@ -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;
}
}