1
- import { ExclamationTriangleIcon } from "@heroicons/react/24/outline" ;
2
1
import { PlusCircleIcon } from "@heroicons/react/20/solid" ;
3
- import { useMemo , forwardRef , useEffect , useCallback } from "react" ;
2
+ import { forwardRef , useEffect , useCallback } from "react" ;
4
3
import {
5
- LuArrowUpFromLine ,
6
- LuCheckCheck ,
7
4
LuLink ,
8
5
LuPlus ,
9
6
LuRadioReceiver ,
@@ -14,38 +11,17 @@ import { useLocation } from "react-router-dom";
14
11
import { Button } from "@components/Button" ;
15
12
import Card , { GridCard } from "@components/Card" ;
16
13
import { formatters } from "@/utils" ;
17
- import { RemoteVirtualMediaState , useMountMediaStore , useRTCStore } from "@/hooks/stores" ;
14
+ import { RemoteVirtualMediaState , useMountMediaStore } from "@/hooks/stores" ;
18
15
import { SettingsPageHeader } from "@components/SettingsPageheader" ;
19
16
import { JsonRpcResponse , useJsonRpc } from "@/hooks/useJsonRpc" ;
20
17
import { useDeviceUiNavigation } from "@/hooks/useAppNavigation" ;
21
18
import notifications from "@/notifications" ;
22
19
23
20
const MountPopopover = forwardRef < HTMLDivElement , object > ( ( _props , ref ) => {
24
- const { diskDataChannelStats } = useRTCStore ( ) ;
25
21
const { send } = useJsonRpc ( ) ;
26
22
const { remoteVirtualMediaState, setModalView, setRemoteVirtualMediaState } =
27
23
useMountMediaStore ( ) ;
28
24
29
- const bytesSentPerSecond = useMemo ( ( ) => {
30
- if ( diskDataChannelStats . size < 2 ) return null ;
31
-
32
- const secondLastItem =
33
- Array . from ( diskDataChannelStats ) [ diskDataChannelStats . size - 2 ] ;
34
- const lastItem = Array . from ( diskDataChannelStats ) [ diskDataChannelStats . size - 1 ] ;
35
-
36
- if ( ! secondLastItem || ! lastItem ) return 0 ;
37
-
38
- const lastTime = lastItem [ 0 ] ;
39
- const secondLastTime = secondLastItem [ 0 ] ;
40
- const timeDelta = lastTime - secondLastTime ;
41
-
42
- const lastBytesSent = lastItem [ 1 ] . bytesSent ;
43
- const secondLastBytesSent = secondLastItem [ 1 ] . bytesSent ;
44
- const bytesDelta = lastBytesSent - secondLastBytesSent ;
45
-
46
- return bytesDelta / timeDelta ;
47
- } , [ diskDataChannelStats ] ) ;
48
-
49
25
const syncRemoteVirtualMediaState = useCallback ( ( ) => {
50
26
send ( "getVirtualMediaState" , { } , ( response : JsonRpcResponse ) => {
51
27
if ( "error" in response ) {
@@ -94,42 +70,6 @@ const MountPopopover = forwardRef<HTMLDivElement, object>((_props, ref) => {
94
70
const { source, filename, size, url, path } = remoteVirtualMediaState ;
95
71
96
72
switch ( source ) {
97
- case "WebRTC" :
98
- return (
99
- < >
100
- < div className = "space-y-1" >
101
- < div className = "flex items-center gap-x-2" >
102
- < LuCheckCheck className = "h-5 text-green-500" />
103
- < h3 className = "text-base font-semibold text-black dark:text-white" >
104
- Streaming from Browser
105
- </ h3 >
106
- </ div >
107
- < Card className = "w-auto px-2 py-1" >
108
- < div className = "w-full truncate text-sm text-black dark:text-white" >
109
- { formatters . truncateMiddle ( filename , 50 ) }
110
- </ div >
111
- </ Card >
112
- </ div >
113
- < div className = "my-2 flex flex-col items-center gap-y-2" >
114
- < div className = "w-full text-sm text-slate-900 dark:text-slate-100" >
115
- < div className = "flex items-center justify-between" >
116
- < span > { formatters . bytes ( size ?? 0 ) } </ span >
117
- < div className = "flex items-center gap-x-1" >
118
- < LuArrowUpFromLine
119
- className = "h-4 text-blue-700 dark:text-blue-500"
120
- strokeWidth = { 2 }
121
- />
122
- < span >
123
- { bytesSentPerSecond !== null
124
- ? `${ formatters . bytes ( bytesSentPerSecond ) } /s`
125
- : "N/A" }
126
- </ span >
127
- </ div >
128
- </ div >
129
- </ div >
130
- </ div >
131
- </ >
132
- ) ;
133
73
case "HTTP" :
134
74
return (
135
75
< div className = "" >
@@ -202,18 +142,7 @@ const MountPopopover = forwardRef<HTMLDivElement, object>((_props, ref) => {
202
142
description = "Mount an image to boot from or install an operating system."
203
143
/>
204
144
205
- { remoteVirtualMediaState ?. source === "WebRTC" ? (
206
- < Card >
207
- < div className = "flex items-center gap-x-1.5 px-2.5 py-2 text-sm" >
208
- < ExclamationTriangleIcon className = "h-4 text-yellow-500" />
209
- < div className = "flex w-full items-center text-black" >
210
- < div > Closing this tab will unmount the image</ div >
211
- </ div >
212
- </ div >
213
- </ Card >
214
- ) : null }
215
-
216
- < div
145
+ < div
217
146
className = "animate-fadeIn opacity-0 space-y-2"
218
147
style = { {
219
148
animationDuration : "0.7s" ,
0 commit comments