Fix async callbacks: make rename/change_path directly async
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -341,8 +341,7 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state,
|
||||
# --- Action row ---
|
||||
with ui.row().classes('w-full q-gutter-sm action-row'):
|
||||
# Rename
|
||||
def rename(idx=i, s=seq, exp=expansion):
|
||||
async def do_rename():
|
||||
async def rename(idx=i, s=seq, exp=expansion):
|
||||
result = await ui.run_javascript(
|
||||
f'prompt("Rename sequence:", {json.dumps(s.get("name", ""))})',
|
||||
timeout=30.0,
|
||||
@@ -350,7 +349,6 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state,
|
||||
if result is not None:
|
||||
s['name'] = result
|
||||
commit('Renamed!')
|
||||
await do_rename()
|
||||
|
||||
ui.button('Rename', icon='edit', on_click=rename).props('outline')
|
||||
# Copy from source
|
||||
|
||||
@@ -110,8 +110,7 @@ def render_projects_tab(state: AppState):
|
||||
ui.button('Deactivate', icon='cancel',
|
||||
on_click=deactivate).props('flat dense')
|
||||
|
||||
def rename_proj(name=proj['name']):
|
||||
async def do_rename():
|
||||
async def rename_proj(name=proj['name']):
|
||||
new_name = await ui.run_javascript(
|
||||
f'prompt("Rename project:", {json.dumps(name)})',
|
||||
timeout=30.0,
|
||||
@@ -130,13 +129,11 @@ def render_projects_tab(state: AppState):
|
||||
render_project_list.refresh()
|
||||
except Exception as e:
|
||||
ui.notify(f'Error: {e}', type='negative')
|
||||
await do_rename()
|
||||
|
||||
ui.button('Rename', icon='edit',
|
||||
on_click=rename_proj).props('flat dense')
|
||||
|
||||
def change_path(name=proj['name'], path=proj['folder_path']):
|
||||
async def do_change():
|
||||
async def change_path(name=proj['name'], path=proj['folder_path']):
|
||||
new_path = await ui.run_javascript(
|
||||
f'prompt("New path for project:", {json.dumps(path)})',
|
||||
timeout=30.0,
|
||||
@@ -146,7 +143,6 @@ def render_projects_tab(state: AppState):
|
||||
state.db.update_project_path(name, new_path)
|
||||
ui.notify(f'Path updated to "{new_path}"', type='positive')
|
||||
render_project_list.refresh()
|
||||
await do_change()
|
||||
|
||||
ui.button('Path', icon='folder',
|
||||
on_click=change_path).props('flat dense')
|
||||
|
||||
Reference in New Issue
Block a user