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 ---
|
# --- 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,
|
||||||
@@ -350,7 +349,6 @@ def _render_sequence_card(i, seq, batch_list, data, file_path, state,
|
|||||||
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
|
||||||
|
|||||||
@@ -110,8 +110,7 @@ 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,
|
||||||
@@ -130,13 +129,11 @@ def render_projects_tab(state: AppState):
|
|||||||
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,
|
||||||
@@ -146,7 +143,6 @@ def render_projects_tab(state: AppState):
|
|||||||
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')
|
||||||
|
|||||||
Reference in New Issue
Block a user