Skip to content

Commit 72fa8e9

Browse files
committed
cleanup
1 parent b97b6ec commit 72fa8e9

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/lib/hooks/create-robot-query.svelte.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export const createRobotQuery = <T extends RobotClient, K extends keyof T>(
3838
]
3939
| [options?: (() => QueryOptions) | QueryOptions]
4040
): { current: QueryObserverResult<ResolvedReturnType<T[K]>> } => {
41-
const connectionStatus = useConnectionStatus();
41+
const partID = $derived((client.current as T & { partID: string })?.partID);
42+
const connectionStatus = useConnectionStatus(() => partID);
4243
const debug = useQueryLogger();
4344
const enabledQueries = useEnabledQueries();
4445
let [args, options] = additional;
@@ -48,6 +49,7 @@ export const createRobotQuery = <T extends RobotClient, K extends keyof T>(
4849
args = undefined;
4950
}
5051

52+
$inspect(connectionStatus.current, MachineConnectionEvent.CONNECTED);
5153
const _options = $derived(
5254
typeof options === 'function' ? options() : options
5355
);
@@ -59,13 +61,14 @@ export const createRobotQuery = <T extends RobotClient, K extends keyof T>(
5961
_options?.enabled !== false &&
6062
enabledQueries.robotQueries
6163
);
64+
$inspect(enabled);
6265

6366
const queryOptions = $derived(
6467
createQueryOptions({
6568
queryKey: [
6669
'viam-svelte-sdk',
6770
'partID',
68-
(client.current as T & { partID: string })?.partID,
71+
partID,
6972
'robotClient',
7073
methodName,
7174
...(_args ? [_args] : []),

src/routes/components/parts.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ let streaming = true;
3535
</button>
3636

3737
{#if id === partID.current}
38+
<Version partID={id} />
39+
3840
<Part partID={id} />
3941
{/if}
4042
{/each}
4143

4244
{status.current}
4345
</div>
4446

45-
<Version {partID} />
46-
4747
<h2 class="py-2">Resources</h2>
4848
{#if resources.error}
4949
Error fetching: {resources.error.message}

src/routes/components/version.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ let { partID } = $props();
66
const client = useRobotClient(() => partID);
77
const version = createRobotQuery(client, 'getVersion');
88
const stopAll = createRobotMutation(client, 'stopAll');
9+
10+
$inspect(version.current);
911
</script>
1012

1113
{#if version.current.error}

0 commit comments

Comments
 (0)