generated from nhcarrigan/template
fix: critical permission modal and config issues #127
+18
-21
@@ -92,6 +92,14 @@ function createConfigStore() {
|
||||
const isSidebarOpen = writable<boolean>(false);
|
||||
const saveError = writable<string | null>(null);
|
||||
|
||||
// Internal function to get current config synchronously
|
||||
function getCurrentConfig(): HikariConfig {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
const unsubscribe = config.subscribe((c) => (currentConfig = c));
|
||||
unsubscribe();
|
||||
return currentConfig;
|
||||
}
|
||||
|
||||
async function loadConfig() {
|
||||
isLoading.set(true);
|
||||
try {
|
||||
@@ -119,8 +127,7 @@ function createConfigStore() {
|
||||
}
|
||||
|
||||
async function updateConfig(updates: Partial<HikariConfig>) {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
const newConfig = { ...currentConfig, ...updates };
|
||||
await saveConfig(newConfig);
|
||||
}
|
||||
@@ -145,15 +152,13 @@ function createConfigStore() {
|
||||
updates.custom_theme_colors = customColors;
|
||||
}
|
||||
await updateConfig(updates);
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
applyTheme(theme, currentConfig.custom_theme_colors);
|
||||
},
|
||||
|
||||
setCustomThemeColors: async (colors: CustomThemeColors) => {
|
||||
await updateConfig({ custom_theme_colors: colors });
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
if (currentConfig.theme === "custom") {
|
||||
applyCustomThemeColors(colors);
|
||||
}
|
||||
@@ -166,16 +171,14 @@ function createConfigStore() {
|
||||
},
|
||||
|
||||
increaseFontSize: async () => {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
const newSize = Math.min(MAX_FONT_SIZE, currentConfig.font_size + 2);
|
||||
await updateConfig({ font_size: newSize });
|
||||
applyFontSize(newSize);
|
||||
},
|
||||
|
||||
decreaseFontSize: async () => {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
const newSize = Math.max(MIN_FONT_SIZE, currentConfig.font_size - 2);
|
||||
await updateConfig({ font_size: newSize });
|
||||
applyFontSize(newSize);
|
||||
@@ -187,8 +190,7 @@ function createConfigStore() {
|
||||
},
|
||||
|
||||
addAutoGrantedTool: async (tool: string) => {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
if (!currentConfig.auto_granted_tools.includes(tool)) {
|
||||
const newTools = [...currentConfig.auto_granted_tools, tool];
|
||||
await updateConfig({ auto_granted_tools: newTools });
|
||||
@@ -196,27 +198,22 @@ function createConfigStore() {
|
||||
},
|
||||
|
||||
removeAutoGrantedTool: async (tool: string) => {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
const newTools = currentConfig.auto_granted_tools.filter((t) => t !== tool);
|
||||
await updateConfig({ auto_granted_tools: newTools });
|
||||
},
|
||||
|
||||
getConfig: (): HikariConfig => {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
return currentConfig;
|
||||
return getCurrentConfig();
|
||||
},
|
||||
|
||||
toggleStreamerMode: async () => {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
await updateConfig({ streamer_mode: !currentConfig.streamer_mode });
|
||||
},
|
||||
|
||||
toggleCompactMode: async () => {
|
||||
let currentConfig: HikariConfig = defaultConfig;
|
||||
config.subscribe((c) => (currentConfig = c))();
|
||||
const currentConfig = getCurrentConfig();
|
||||
await updateConfig({ compact_mode: !currentConfig.compact_mode });
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user