@@ -19,14 +19,12 @@ import { CLOUD_API, DEVICE_API } from "@/ui.config";
1919import api from "@/api" ;
2020import { checkAuth , isInCloud , isOnDevice } from "@/main" ;
2121import { cx } from "@/cva.config" ;
22- import notifications from "@/notifications" ;
2322import {
2423 KeyboardLedState ,
2524 KeysDownState ,
2625 NetworkState ,
2726 OtaState ,
2827 USBStates ,
29- useDeviceStore ,
3028 useHidStore ,
3129 useNetworkStateStore ,
3230 User ,
@@ -42,7 +40,7 @@ const ConnectionStatsSidebar = lazy(() => import('@/components/sidebar/connectio
4240const Terminal = lazy ( ( ) => import ( '@components/Terminal' ) ) ;
4341const UpdateInProgressStatusCard = lazy ( ( ) => import ( "@/components/UpdateInProgressStatusCard" ) ) ;
4442import Modal from "@/components/Modal" ;
45- import { JsonRpcRequest , JsonRpcResponse , useJsonRpc } from "@/hooks/useJsonRpc" ;
43+ import { JsonRpcRequest , JsonRpcResponse , RpcMethodNotFound , useJsonRpc } from "@/hooks/useJsonRpc" ;
4644import {
4745 ConnectionFailedOverlay ,
4846 LoadingConnectionOverlay ,
@@ -51,7 +49,7 @@ import {
5149import { useDeviceUiNavigation } from "@/hooks/useAppNavigation" ;
5250import { FeatureFlagProvider } from "@/providers/FeatureFlagProvider" ;
5351import { DeviceStatus } from "@routes/welcome-local" ;
54- import { SystemVersionInfo } from "@routes/devices.$id.settings.general.update " ;
52+ import { useVersion } from "@/hooks/useVersion " ;
5553
5654interface LocalLoaderResp {
5755 authMode : "password" | "noPassword" | null ;
@@ -715,7 +713,7 @@ export default function KvmIdRoute() {
715713 send ( "getKeyDownState" , { } , ( resp : JsonRpcResponse ) => {
716714 if ( "error" in resp ) {
717715 // -32601 means the method is not supported
718- if ( resp . error . code === - 32601 ) {
716+ if ( resp . error . code === RpcMethodNotFound ) {
719717 // if we don't support key down state, we know key press is also not available
720718 console . warn ( "Failed to get key down state, switching to old-school" , resp . error ) ;
721719 setHidRpcDisabled ( true ) ;
@@ -758,26 +756,13 @@ export default function KvmIdRoute() {
758756 if ( location . pathname !== "/other-session" ) navigateTo ( "/" ) ;
759757 } , [ navigateTo , location . pathname ] ) ;
760758
761- const { appVersion, setAppVersion , setSystemVersion } = useDeviceStore ( ) ;
759+ const { appVersion, getLocalVersion } = useVersion ( ) ;
762760
763761 useEffect ( ( ) => {
764762 if ( appVersion ) return ;
765763
766- send ( "getUpdateStatus" , { } , ( resp : JsonRpcResponse ) => {
767- if ( "error" in resp ) {
768- notifications . error ( `Failed to get device version: ${ resp . error } ` ) ;
769- return
770- }
771-
772- const result = resp . result as SystemVersionInfo ;
773- if ( result . error ) {
774- notifications . error ( `Failed to get device version: ${ result . error } ` ) ;
775- }
776-
777- setAppVersion ( result . local . appVersion ) ;
778- setSystemVersion ( result . local . systemVersion ) ;
779- } ) ;
780- } , [ appVersion , send , setAppVersion , setSystemVersion ] ) ;
764+ getLocalVersion ( ) ;
765+ } , [ appVersion , getLocalVersion ] ) ;
781766
782767 const ConnectionStatusElement = useMemo ( ( ) => {
783768 const hasConnectionFailed =
0 commit comments