Skip to content

Commit 3a0df04

Browse files
Receive notifications on the client.
1 parent da9c17a commit 3a0df04

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

app/src/organisms/LabwarePositionCheck/LPCFlows/hooks/useLPCLabwareInfo/index.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useMemo } from 'react'
22

3-
import { useSearchLabwareOffsets } from '@opentrons/react-api-client'
43
import { FLEX_ROBOT_TYPE, OT2_ROBOT_TYPE } from '@opentrons/shared-data'
54
import { RUN_STATUS_IDLE } from '@opentrons/api-client'
65

76
import { getUniqueValidLwLocationInfoByAnalysis } from './getUniqueValidLwLocationInfoByAnalysis'
87
import { getLPCLabwareInfoFrom } from './getLPCLabwareInfoFrom'
98
import { getLPCSearchParams } from './getLPCSearchParams'
9+
import { useNotifySearchLabwareOffsets } from '/app/resources/labware_offsets'
1010
import { useNotifyRunQuery, useRunStatus } from '/app/resources/runs'
1111

1212
import type { LabwareOffset, StoredLabwareOffset } from '@opentrons/api-client'
@@ -66,11 +66,7 @@ function useFlexLPCLabwareInfo({
6666
[lwLocationCombos.length]
6767
)
6868

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, {
7470
enabled:
7571
searchLwOffsetsParams.filters.length > 0 &&
7672
robotType === FLEX_ROBOT_TYPE &&

app/src/redux/shell/types.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,14 @@ export interface RobotMassStorageDeviceRemoved {
146146

147147
export type NotifyTopic =
148148
| 'ALL_TOPICS'
149+
| `robot-server/clientData/${string}`
150+
| 'robot-server/deck_configuration'
151+
| 'robot-server/labwareOffsets'
149152
| 'robot-server/maintenance_runs/current_run'
150153
| 'robot-server/runs/commands_links'
151154
| 'robot-server/runs'
152155
| `robot-server/runs/${string}`
153-
| 'robot-server/deck_configuration'
154156
| `robot-server/runs/pre_serialized_commands/${string}`
155-
| `robot-server/clientData/${string}`
156157

157158
export interface NotifySubscribeAction {
158159
type: 'shell:NOTIFY_SUBSCRIBE'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './useNotifyLabwareOffsetsQuery'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

0 commit comments

Comments
 (0)