Add Fava settings UI and fix race conditions in toolbar buttons
- Add Fava URL, ledger slug, and timeout settings to super admin Settings dialog - Reinitialize Fava client when settings are updated via services.py - Add settingsLoaded flag to prevent race conditions where wrong toolbar buttons appeared before isSuperUser was determined - Remove premature Vue mount() call from permissions.js that caused "Cannot read properties of undefined (reading 'user')" error 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
5eb007b936
commit
cb9bc2d658
4 changed files with 83 additions and 10 deletions
17
services.py
17
services.py
|
|
@ -18,12 +18,29 @@ async def get_settings(user_id: str) -> CastleSettings:
|
|||
|
||||
|
||||
async def update_settings(user_id: str, data: CastleSettings) -> CastleSettings:
|
||||
from loguru import logger
|
||||
|
||||
from .fava_client import init_fava_client
|
||||
|
||||
settings = await get_castle_settings(user_id)
|
||||
if not settings:
|
||||
settings = await create_castle_settings(user_id, data)
|
||||
else:
|
||||
settings = await update_castle_settings(user_id, data)
|
||||
|
||||
# Reinitialize Fava client with new settings
|
||||
try:
|
||||
init_fava_client(
|
||||
fava_url=settings.fava_url,
|
||||
ledger_slug=settings.fava_ledger_slug,
|
||||
timeout=settings.fava_timeout,
|
||||
)
|
||||
logger.info(
|
||||
f"Fava client reinitialized: {settings.fava_url}/{settings.fava_ledger_slug}"
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to reinitialize Fava client: {e}")
|
||||
|
||||
return settings
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue