[deploy]
All checks were successful
Deploy Discord Bot / deploy (push) Successful in 37s

This commit is contained in:
Pascal Prießnitz
2025-12-04 16:43:38 +01:00
parent 311f5a87f1
commit 22caa79b54
60 changed files with 2652 additions and 2999 deletions

49
public/ts/state/store.ts Normal file
View File

@@ -0,0 +1,49 @@
export interface AppConfig {
baseRoot: string;
baseDashboard: string;
baseAuth: string;
baseApi: string;
view: 'selection' | 'dashboard';
initialGuildId?: string;
isAdmin?: boolean;
userLabel?: string;
}
export interface AppState {
guildId?: string;
isAdmin?: boolean;
userLabel?: string;
}
type Listener = (state: AppState) => void;
let config: AppConfig | null = null;
let state: AppState = {};
const listeners = new Set<Listener>();
export function initConfig(next: AppConfig) {
config = next;
state = {
guildId: next.initialGuildId,
isAdmin: next.isAdmin,
userLabel: next.userLabel
};
}
export function getConfig() {
return config;
}
export function getState() {
return state;
}
export function setState(partial: Partial<AppState>) {
state = { ...state, ...partial };
listeners.forEach((l) => l(state));
}
export function subscribe(listener: Listener) {
listeners.add(listener);
return () => listeners.delete(listener);
}