@@ -19,14 +19,12 @@ import { CLOUD_API, DEVICE_API } from "@/ui.config";
19
19
import api from "@/api" ;
20
20
import { checkAuth , isInCloud , isOnDevice } from "@/main" ;
21
21
import { cx } from "@/cva.config" ;
22
- import notifications from "@/notifications" ;
23
22
import {
24
23
KeyboardLedState ,
25
24
KeysDownState ,
26
25
NetworkState ,
27
26
OtaState ,
28
27
USBStates ,
29
- useDeviceStore ,
30
28
useHidStore ,
31
29
useNetworkStateStore ,
32
30
User ,
@@ -42,7 +40,7 @@ const ConnectionStatsSidebar = lazy(() => import('@/components/sidebar/connectio
42
40
const Terminal = lazy ( ( ) => import ( '@components/Terminal' ) ) ;
43
41
const UpdateInProgressStatusCard = lazy ( ( ) => import ( "@/components/UpdateInProgressStatusCard" ) ) ;
44
42
import Modal from "@/components/Modal" ;
45
- import { JsonRpcRequest , JsonRpcResponse , useJsonRpc } from "@/hooks/useJsonRpc" ;
43
+ import { JsonRpcRequest , JsonRpcResponse , RpcMethodNotFound , useJsonRpc } from "@/hooks/useJsonRpc" ;
46
44
import {
47
45
ConnectionFailedOverlay ,
48
46
LoadingConnectionOverlay ,
@@ -51,7 +49,7 @@ import {
51
49
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation" ;
52
50
import { FeatureFlagProvider } from "@/providers/FeatureFlagProvider" ;
53
51
import { DeviceStatus } from "@routes/welcome-local" ;
54
- import { SystemVersionInfo } from "@routes/devices.$id.settings.general.update " ;
52
+ import { useVersion } from "@/hooks/useVersion " ;
55
53
56
54
interface LocalLoaderResp {
57
55
authMode : "password" | "noPassword" | null ;
@@ -715,7 +713,7 @@ export default function KvmIdRoute() {
715
713
send ( "getKeyDownState" , { } , ( resp : JsonRpcResponse ) => {
716
714
if ( "error" in resp ) {
717
715
// -32601 means the method is not supported
718
- if ( resp . error . code === - 32601 ) {
716
+ if ( resp . error . code === RpcMethodNotFound ) {
719
717
// if we don't support key down state, we know key press is also not available
720
718
console . warn ( "Failed to get key down state, switching to old-school" , resp . error ) ;
721
719
setHidRpcDisabled ( true ) ;
@@ -758,26 +756,13 @@ export default function KvmIdRoute() {
758
756
if ( location . pathname !== "/other-session" ) navigateTo ( "/" ) ;
759
757
} , [ navigateTo , location . pathname ] ) ;
760
758
761
- const { appVersion, setAppVersion , setSystemVersion } = useDeviceStore ( ) ;
759
+ const { appVersion, getLocalVersion } = useVersion ( ) ;
762
760
763
761
useEffect ( ( ) => {
764
762
if ( appVersion ) return ;
765
763
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 ] ) ;
781
766
782
767
const ConnectionStatusElement = useMemo ( ( ) => {
783
768
const hasConnectionFailed =
0 commit comments