Fix async callbacks: make rename/change_path directly async

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 00:42:00 +01:00
parent 204fc4ea85
commit 60d1162700
2 changed files with 37 additions and 43 deletions

View File

@@ -341,16 +341,14 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state,
# --- Action row --- # --- Action row ---
with ui.row().classes('w-full q-gutter-sm action-row'): with ui.row().classes('w-full q-gutter-sm action-row'):
# Rename # Rename
def rename(idx=i, s=seq, exp=expansion): async def rename(idx=i, s=seq, exp=expansion):
async def do_rename(): result = await ui.run_javascript(
result = await ui.run_javascript( f'prompt("Rename sequence:", {json.dumps(s.get("name", ""))})',
f'prompt("Rename sequence:", {json.dumps(s.get("name", ""))})', timeout=30.0,
timeout=30.0, )
) if result is not None:
if result is not None: s['name'] = result
s['name'] = result commit('Renamed!')
commit('Renamed!')
await do_rename()
ui.button('Rename', icon='edit', on_click=rename).props('outline') ui.button('Rename', icon='edit', on_click=rename).props('outline')
# Copy from source # Copy from source

View File

@@ -110,43 +110,39 @@ def render_projects_tab(state: AppState):
ui.button('Deactivate', icon='cancel', ui.button('Deactivate', icon='cancel',
on_click=deactivate).props('flat dense') on_click=deactivate).props('flat dense')
def rename_proj(name=proj['name']): async def rename_proj(name=proj['name']):
async def do_rename(): new_name = await ui.run_javascript(
new_name = await ui.run_javascript( f'prompt("Rename project:", {json.dumps(name)})',
f'prompt("Rename project:", {json.dumps(name)})', timeout=30.0,
timeout=30.0, )
) if new_name and new_name.strip() and new_name.strip() != name:
if new_name and new_name.strip() and new_name.strip() != name: new_name = new_name.strip()
new_name = new_name.strip() try:
try: state.db.rename_project(name, new_name)
state.db.rename_project(name, new_name) if state.current_project == name:
if state.current_project == name: state.current_project = new_name
state.current_project = new_name state.config['current_project'] = new_name
state.config['current_project'] = new_name save_config(state.current_dir,
save_config(state.current_dir, state.config.get('favorites', []),
state.config.get('favorites', []), state.config)
state.config) ui.notify(f'Renamed to "{new_name}"', type='positive')
ui.notify(f'Renamed to "{new_name}"', type='positive') render_project_list.refresh()
render_project_list.refresh() except Exception as e:
except Exception as e: ui.notify(f'Error: {e}', type='negative')
ui.notify(f'Error: {e}', type='negative')
await do_rename()
ui.button('Rename', icon='edit', ui.button('Rename', icon='edit',
on_click=rename_proj).props('flat dense') on_click=rename_proj).props('flat dense')
def change_path(name=proj['name'], path=proj['folder_path']): async def change_path(name=proj['name'], path=proj['folder_path']):
async def do_change(): new_path = await ui.run_javascript(
new_path = await ui.run_javascript( f'prompt("New path for project:", {json.dumps(path)})',
f'prompt("New path for project:", {json.dumps(path)})', timeout=30.0,
timeout=30.0, )
) if new_path and new_path.strip() and new_path.strip() != path:
if new_path and new_path.strip() and new_path.strip() != path: new_path = new_path.strip()
new_path = new_path.strip() state.db.update_project_path(name, new_path)
state.db.update_project_path(name, new_path) ui.notify(f'Path updated to "{new_path}"', type='positive')
ui.notify(f'Path updated to "{new_path}"', type='positive') render_project_list.refresh()
render_project_list.refresh()
await do_change()
ui.button('Path', icon='folder', ui.button('Path', icon='folder',
on_click=change_path).props('flat dense') on_click=change_path).props('flat dense')