Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
fix: diff syntax error
Browse files Browse the repository at this point in the history
auto select the only controller
  • Loading branch information
neko-para committed Nov 2, 2023
1 parent 4880c69 commit 1efc9d7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
12 changes: 11 additions & 1 deletion app/renderer/src/stores/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ function init_from(handle: ControllerHandle) {
return Controller.init_from(handle, handles.value[handle]!.cb)
}

function only_one() {
const ks = Object.keys(handles.value)
if (ks.length === 1) {
return ks[0] as ControllerHandle
} else {
return null
}
}

export const useController = {
handles,

Expand All @@ -83,5 +92,6 @@ export const useController = {
disconnect_all,
find,
info,
init_from
init_from,
only_one
}
10 changes: 8 additions & 2 deletions app/renderer/src/stores/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ watch(
async function create_with(cfg: InstanceSaveInfo) {
const inst = await Instance.init()
const res = await Resource.init()
const ctrl = useController.only_one()
handles.value[inst.handle] = {
...cfg,
runtime: {
Expand All @@ -64,7 +65,8 @@ async function create_with(cfg: InstanceSaveInfo) {
resource: {
handle: res.handle,
cb: res.cbId
}
},
controller: ctrl
}
}
return inst
Expand Down Expand Up @@ -297,7 +299,11 @@ async function run(
merge(finalDiff, entry.provide ?? {})

console.log(entry.task, finalDiff)
await hinst.post_task(entry.task, finalDiff).wait()
await hinst
.post_task(entry.task, {
diff_task: finalDiff
})
.wait()
}

output.state = RunningState.Idle
Expand Down
4 changes: 2 additions & 2 deletions app/renderer/src/views/Devices/DevicesSide.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function dropSaved(serial: string) {
</div>
<NCard :title="t('device.side.connected')" :theme-overrides="{ color: 'transparent' }">
<div class="flex flex-col gap-2">
<div class="flex gap-2" v-for="(item, idx) of connectDevices" :key="idx">
<div class="flex gap-2 items-center" v-for="(item, idx) of connectDevices" :key="idx">
<NButton
@click="curDevice = item"
secondary
Expand Down Expand Up @@ -96,7 +96,7 @@ function dropSaved(serial: string) {
</NCard>
<NCard :title="t('device.side.disconnected')" :theme-overrides="{ color: 'transparent' }">
<div class="flex flex-col gap-2">
<div class="flex gap-2" v-for="(item, idx) of foundDevices" :key="idx">
<div class="flex gap-2 items-center" v-for="(item, idx) of foundDevices" :key="idx">
<NButton
@click="curDevice = idx"
secondary
Expand Down
2 changes: 1 addition & 1 deletion pkgs/type/src/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type InstanceSaveInfo = {

export type InstanceHandleInfo = InstanceSaveInfo & {
runtime: {
controller?: ControllerHandle
controller?: ControllerHandle | null
resource: {
handle: ResourceHandle
cb: string
Expand Down

0 comments on commit 1efc9d7

Please sign in to comment.