mirror of
https://github.com/Stef-00012/Zipline-Android-App.git
synced 2025-05-11 10:25:59 +02:00
handle user menu, finish server settings, add tmporary WIP page for undone pages
This commit is contained in:
parent
8d295153bc
commit
c05a29c21d
14 changed files with 1686 additions and 1109 deletions
|
@ -96,38 +96,4 @@ export function colorHash(str: string) {
|
|||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: can't know the type of the key
|
||||
export function getObjectValue<T extends Record<string, any> = Record<string, any>>(obj: T, path: string): T[keyof T] | undefined {
|
||||
const keys = path.split(".");
|
||||
let result = obj;
|
||||
|
||||
for (const key of keys) {
|
||||
if (result[key] === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
result = result[key];
|
||||
}
|
||||
|
||||
return result as T[keyof T];
|
||||
}
|
||||
|
||||
// biome-ignore lint/suspicious/noExplicitAny: can't know the type of the key
|
||||
export function setObjectValue<T extends Record<string, any> = Record<string, any>>(obj: T, path: string, value: any): T {
|
||||
const keys = path.split(".");
|
||||
let result = obj;
|
||||
|
||||
for (let i = 0; i < keys.length - 1; i++) {
|
||||
if (result[keys[i]] === undefined) {
|
||||
(result as Record<string, unknown>)[keys[i]] = {};
|
||||
}
|
||||
|
||||
result = result[keys[i]];
|
||||
}
|
||||
|
||||
(result as Record<string, unknown>)[keys[keys.length - 1]] = value;
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue