DebugLabelsStore -> DebugLabelsState

This commit is contained in:
azykov@mail.ru
2026-06-18 10:28:31 +03:00
parent 9d0f97e9ea
commit 076cded364
4 changed files with 5 additions and 5 deletions
+39
View File
@@ -0,0 +1,39 @@
import { makeAutoObservable } from "mobx";
class DebugLabelsState {
public labels = new Map<string, Record<string, string>>();
constructor() {
makeAutoObservable(this);
}
public getAll(objectId: string): Record<string, string> {
return this.labels.get(objectId) ?? {};
}
public getOne(objectId: string, key: string): string | undefined {
return this.getAll(objectId)[key];
}
public setOne(objectId: string, key: string, text: string) {
if (!this.labels.has(objectId))
this.labels.set(objectId, {});
this.labels.get(objectId)![key] = text;
}
public deleteAll(objectId: string) {
this.labels.delete(objectId);
}
public deleteOne(objectId: string, key: string) {
if (this.labels.has(objectId)) {
delete (this.labels.get(objectId)![key]);
}
}
public clear() {
this.labels.clear();
}
}
export const debugLabelsStore = new DebugLabelsState();