Skip to content

Commit ee3f11a

Browse files
authored
fix: refresh device list on pair (commaai#520)
the device list doesn't refresh when you finish pairing your device. now, we refetch the list upon a successful pair
1 parent 3c7baa5 commit ee3f11a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/pages/dashboard/Dashboard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ const Dashboard: Component<RouteSectionProps> = () => {
114114
}
115115
})
116116

117-
const [devices] = createResource(getDevices, { initialValue: [] })
117+
const [devices, { refetch }] = createResource(getDevices, { initialValue: [] })
118118
const [profile] = createResource(getProfile)
119119

120120
const getDefaultDongleId = () => {
@@ -130,7 +130,7 @@ const Dashboard: Component<RouteSectionProps> = () => {
130130
<Drawer drawer={<DashboardDrawer devices={devices()} />}>
131131
<Switch fallback={<TopAppBar leading={<DrawerToggleButton />}>No device</TopAppBar>}>
132132
<Match when={urlState().dongleId === 'pair' || !!location.query.pair}>
133-
<PairActivity />
133+
<PairActivity onPaired={refetch} />
134134
</Match>
135135
<Match when={urlState().dongleId} keyed>
136136
{(dongleId) => (

src/pages/dashboard/activities/PairActivity.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import TopAppBar from '~/components/material/TopAppBar'
1111

1212
import './PairActivity.css'
1313

14-
const PairActivity: VoidComponent = () => {
14+
const PairActivity: VoidComponent<{ onPaired: () => void }> = (props) => {
1515
const { pair } = useLocation().query
1616
const pairToken: string | undefined = Array.isArray(pair) ? pair[0] : pair
1717

@@ -79,6 +79,7 @@ const PairActivity: VoidComponent = () => {
7979

8080
pairDevice(input.pairToken)
8181
.then((dongleId) => navigate(`/${dongleId}`))
82+
.then(props.onPaired)
8283
.catch((reason) => {
8384
let error: Error
8485
if (reason instanceof Error) {

0 commit comments

Comments
 (0)