diff --git a/package-lock.json b/package-lock.json
index d0a5a0098..039577c72 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14786,7 +14786,7 @@
},
"node_modules/solarxr-protocol": {
"version": "1.0.0",
- "resolved": "git+ssh://git@github.com/SlimeVR/SolarXR-Protocol.git#f588c2e4adc70480d7dfe23f77621d1f2183ed47",
+ "resolved": "git+ssh://git@github.com/SlimeVR/SolarXR-Protocol.git#c6db24ca7f99dea8c093106cd30e36a3451d9f7c",
"license": "(MIT OR Apache-2.0)",
"dependencies": {
"flatbuffers": "^2.0.6"
@@ -25346,7 +25346,7 @@
}
},
"solarxr-protocol": {
- "version": "git+ssh://git@github.com/SlimeVR/SolarXR-Protocol.git#f588c2e4adc70480d7dfe23f77621d1f2183ed47",
+ "version": "git+ssh://git@github.com/SlimeVR/SolarXR-Protocol.git#c6db24ca7f99dea8c093106cd30e36a3451d9f7c",
"from": "solarxr-protocol@github:SlimeVR/SolarXR-Protocol",
"requires": {
"flatbuffers": "^2.0.6"
diff --git a/src/components/MainLayout.tsx b/src/components/MainLayout.tsx
index ba7bbd4cb..f0b13312d 100644
--- a/src/components/MainLayout.tsx
+++ b/src/components/MainLayout.tsx
@@ -44,6 +44,7 @@ export function MainLayoutRoute({
+
diff --git a/src/components/commons/icon/ResetIcon.tsx b/src/components/commons/icon/ResetIcon.tsx
index c6f7c067a..4c7778e92 100644
--- a/src/components/commons/icon/ResetIcon.tsx
+++ b/src/components/commons/icon/ResetIcon.tsx
@@ -54,3 +54,29 @@ export function QuickResetIcon({ width = 33 }: { width?: number }) {
);
}
+
+export function MountingResetIcon({ width = 33 }: { width?: number }) {
+ return (
+
+ );
+}
diff --git a/src/components/home/ResetButton.tsx b/src/components/home/ResetButton.tsx
index 5e7691ba0..6758f9815 100644
--- a/src/components/home/ResetButton.tsx
+++ b/src/components/home/ResetButton.tsx
@@ -2,7 +2,11 @@ import { useRef, useState } from 'react';
import { ResetRequestT, ResetType, RpcMessage } from 'solarxr-protocol';
import { useWebsocketAPI } from '../../hooks/websocket-api';
import { BigButton } from '../commons/BigButton';
-import { QuickResetIcon, ResetIcon } from '../commons/icon/ResetIcon';
+import {
+ MountingResetIcon,
+ QuickResetIcon,
+ ResetIcon,
+} from '../commons/icon/ResetIcon';
export function ResetButton({ type }: { type: ResetType }) {
const timerid = useRef
(null);
@@ -10,21 +14,52 @@ export function ResetButton({ type }: { type: ResetType }) {
const [timer, setTimer] = useState(0);
const { sendRPCPacket } = useWebsocketAPI();
+ const getText = () => {
+ switch (type) {
+ case ResetType.Quick:
+ return 'Quick Reset';
+ case ResetType.Mounting:
+ return 'Reset Mounting';
+ }
+ return 'Reset';
+ };
+
+ const getIcon = () => {
+ switch (type) {
+ case ResetType.Quick:
+ return ;
+ case ResetType.Mounting:
+ return ;
+ }
+ return ;
+ };
+
const reset = () => {
const req = new ResetRequestT();
req.resetType = type;
setReseting(true);
+ setTimer(0);
if (type !== ResetType.Quick) {
if (timerid.current) clearInterval(timerid.current);
timerid.current = setInterval(() => {
setTimer((timer) => {
- if (timer + 1 === 3) {
+ const newTimer = timer + 1;
+ if (newTimer >= 3) {
+ // Stop the current interval
if (timerid.current) clearInterval(timerid.current);
- sendRPCPacket(RpcMessage.ResetRequest, req);
- setTimer(0);
+
+ // Only actually reset on exactly 0 so it doesn't repeatedly reset if bugged
+ if (newTimer === 3) sendRPCPacket(RpcMessage.ResetRequest, req);
+ else
+ console.warn(
+ `Reset timer is still running after 3 seconds (newTimer = ${newTimer})`
+ );
+
+ // Reset the state
+ // Don't reset the timer in-case the interval keeps running
setReseting(false);
}
- return timer + 1;
+ return newTimer;
});
}, 1000);
} else {
@@ -35,20 +70,8 @@ export function ResetButton({ type }: { type: ResetType }) {
return (
- ) : (
-
- )
- }
+ text={!reseting || timer >= 3 ? getText() : `${3 - timer}`}
+ icon={getIcon()}
onClick={reset}
disabled={reseting}
>