File tree 4 files changed +38
-8
lines changed
organisms/LabwarePositionCheck/LPCFlows/hooks/useLPCLabwareInfo
resources/labware_offsets
4 files changed +38
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { useMemo } from 'react'
2
2
3
- import { useSearchLabwareOffsets } from '@opentrons/react-api-client'
4
3
import { FLEX_ROBOT_TYPE , OT2_ROBOT_TYPE } from '@opentrons/shared-data'
5
4
import { RUN_STATUS_IDLE } from '@opentrons/api-client'
6
5
7
6
import { getUniqueValidLwLocationInfoByAnalysis } from './getUniqueValidLwLocationInfoByAnalysis'
8
7
import { getLPCLabwareInfoFrom } from './getLPCLabwareInfoFrom'
9
8
import { getLPCSearchParams } from './getLPCSearchParams'
9
+ import { useNotifySearchLabwareOffsets } from '/app/resources/labware_offsets'
10
10
import { useNotifyRunQuery , useRunStatus } from '/app/resources/runs'
11
11
12
12
import type { LabwareOffset , StoredLabwareOffset } from '@opentrons/api-client'
@@ -66,11 +66,7 @@ function useFlexLPCLabwareInfo({
66
66
[ lwLocationCombos . length ]
67
67
)
68
68
69
- // TODO(jh, 03-14-25): Add this search route to notifications.
70
-
71
- // We have to poll, because it's possible for a user to update the
72
- // offsets on a different app while a view utilizing this data is active.
73
- const { data } = useSearchLabwareOffsets ( searchLwOffsetsParams , {
69
+ const { data } = useNotifySearchLabwareOffsets ( searchLwOffsetsParams , {
74
70
enabled :
75
71
searchLwOffsetsParams . filters . length > 0 &&
76
72
robotType === FLEX_ROBOT_TYPE &&
Original file line number Diff line number Diff line change @@ -146,13 +146,14 @@ export interface RobotMassStorageDeviceRemoved {
146
146
147
147
export type NotifyTopic =
148
148
| 'ALL_TOPICS'
149
+ | `robot-server/clientData/${string } `
150
+ | 'robot-server/deck_configuration'
151
+ | 'robot-server/labwareOffsets'
149
152
| 'robot-server/maintenance_runs/current_run'
150
153
| 'robot-server/runs/commands_links'
151
154
| 'robot-server/runs'
152
155
| `robot-server/runs/${string } `
153
- | 'robot-server/deck_configuration'
154
156
| `robot-server/runs/pre_serialized_commands/${string } `
155
- | `robot-server/clientData/${string } `
156
157
157
158
export interface NotifySubscribeAction {
158
159
type : 'shell:NOTIFY_SUBSCRIBE'
Original file line number Diff line number Diff line change
1
+ export * from './useNotifyLabwareOffsetsQuery'
Original file line number Diff line number Diff line change
1
+ import { useSearchLabwareOffsets } from '@opentrons/react-api-client'
2
+
3
+ import { useNotifyDataReady } from '../useNotifyDataReady'
4
+
5
+ import type {
6
+ SearchLabwareOffsetsRequest ,
7
+ SearchLabwareOffsetsResponse ,
8
+ } from '@opentrons/api-client'
9
+ import type { AxiosError } from 'axios'
10
+ import type { UseQueryResult } from 'react-query'
11
+ import type { QueryOptionsWithPolling } from '../useNotifyDataReady'
12
+
13
+ export function useNotifySearchLabwareOffsets (
14
+ request : SearchLabwareOffsetsRequest ,
15
+ options : QueryOptionsWithPolling <
16
+ SearchLabwareOffsetsResponse ,
17
+ AxiosError
18
+ > = { }
19
+ ) : UseQueryResult < SearchLabwareOffsetsResponse > {
20
+ const { shouldRefetch, queryOptionsNotify } = useNotifyDataReady ( {
21
+ topic : 'robot-server/labwareOffsets' ,
22
+ options,
23
+ } )
24
+
25
+ const httpQueryResult = useSearchLabwareOffsets ( request , queryOptionsNotify )
26
+
27
+ if ( shouldRefetch ) {
28
+ void httpQueryResult . refetch ( )
29
+ }
30
+
31
+ return httpQueryResult
32
+ }
You can’t perform that action at this time.
0 commit comments