Usenet streaming with a WebDAV server and a SABnzbd-compatible API
C#
Improve live connections widget.
nzbdav-dev646666fd34d9
diff --git a/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.module.css b/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.module.cssindex 9f50ddee..3c6fee36 100644--- a/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.module.css+++ b/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.module.css@@ -8,30 +8,35 @@margin-bottom: 5px;}+.bar {+ position: relative;+ height: 1px;+ margin-bottom: 5px;+}+.max {background-color: #93a1a1;- position: relative;- border-radius: 10px;- height: 10px;- overflow: hidden;+ opacity: 0.25;+ position: absolute;+ height: 100%;+ width: 100%;}.live {- background-color: #eee8d5;+ background-color: green;position: absolute;height: 100%;width: 0%;}.active {- background-color: #268bd2;+ background-color: blue;position: absolute;height: 100%;width: 0%;}.caption {- text-align: right;margin-right: 5px;font-size: 12px;}\ No newline at end of filediff --git a/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.module.css.d.ts b/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.module.css.d.tsindex 7589dbb3..d7e2d026 100644--- a/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.module.css.d.ts+++ b/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.module.css.d.ts@@ -1,6 +1,7 @@declare const styles: {readonly "container": string;readonly "title": string;+ readonly "bar": string;readonly "max": string;readonly "live": string;readonly "active": string;diff --git a/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.tsx b/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.tsxindex 5ec19a97..2fcee330 100644--- a/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.tsx+++ b/frontend/app/routes/_index/components/live-usenet-connections/live-usenet-connections.tsx@@ -12,10 +12,17 @@ export function LiveUsenetConnections() {const livePercent = 100 * (live / max);useEffect(() => {- const ws = new WebSocket(window.location.origin.replace(/^http/, 'ws'));- ws.onmessage = (event) => setConnections(event.data);- ws.onopen = () => ws.send(usenetConnectionsTopic);- return () => ws.close();+ let ws: WebSocket;+ let disposed = false;+ function connect() {+ ws = new WebSocket(window.location.origin.replace(/^http/, 'ws'));+ ws.onmessage = (event) => setConnections(event.data);+ ws.onopen = () => ws.send(usenetConnectionsTopic);+ ws.onclose = () => { !disposed && setTimeout(() => connect(), 1000); setConnections(null) };+ ws.onerror = () => { ws.close() };+ return () => { disposed = true; ws.close(); }+ }+ return connect();}, [setConnections]);return (@@ -23,7 +30,8 @@ export function LiveUsenetConnections() {<div className={styles.title}>Usenet Connections</div>- <div className={styles.max}>+ <div className={styles.bar}>+ <div className={styles.max} /><div className={styles.live} style={{ width: `${livePercent}%` }} /><div className={styles.active} style={{ width: `${activePercent}%` }} /></div>