diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-11-12 16:23:15 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-03-14 13:58:44 +0100 |
| commit | a4a064bdbadaa3c77a63b2deac06d2948246e808 (patch) | |
| tree | 3c164926885b74f2318d4d0daf3f135741c56d68 /gui/src/renderer/components | |
| parent | 61cacab42463bd0913905c31e5da4a69a4c359c7 (diff) | |
| download | mullvadvpn-a4a064bdbadaa3c77a63b2deac06d2948246e808.tar.xz mullvadvpn-a4a064bdbadaa3c77a63b2deac06d2948246e808.zip | |
Switch to using device removal daemon event for device list updates
Diffstat (limited to 'gui/src/renderer/components')
| -rw-r--r-- | gui/src/renderer/components/TooManyDevices.tsx | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/gui/src/renderer/components/TooManyDevices.tsx b/gui/src/renderer/components/TooManyDevices.tsx index 7b434468c7..56ecbd99c1 100644 --- a/gui/src/renderer/components/TooManyDevices.tsx +++ b/gui/src/renderer/components/TooManyDevices.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useEffect } from 'react'; import { sprintf } from 'sprintf-js'; import styled from 'styled-components'; import { colors } from '../../config.json'; @@ -91,18 +91,13 @@ const StyledRemoveDeviceButton = styled.button({ export default function TooManyDevices() { const history = useHistory(); - const { listDevices, removeDevice, login, cancelLogin } = useAppContext(); + const { fetchDevices, removeDevice, login, cancelLogin } = useAppContext(); const accountToken = useSelector((state) => state.account.accountToken)!; - const [devices, setDevices] = useState<Array<IDevice>>(); - - const fetchDevices = useCallback(async () => { - setDevices(await listDevices(accountToken)); - }, [listDevices, accountToken]); + const devices = useSelector((state) => state.account.devices); const onRemoveDevice = useCallback( async (deviceId: string) => { await removeDevice({ accountToken, deviceId }); - await fetchDevices(); }, [removeDevice, accountToken], ); @@ -113,7 +108,7 @@ export default function TooManyDevices() { history.reset(RoutePath.login, transitions.pop); }, [history.reset, cancelLogin]); - useEffect(() => void fetchDevices(), []); + useEffect(() => void fetchDevices(accountToken), []); const iconSource = getIconSource(devices); const title = getTitle(devices); |
