Просмотр исходного кода

Auto-navigate SpoolBuddy to dashboard on tag scan

  When an NFC tag is first detected while the UI is on a non-dashboard
  page, automatically navigate to the main dashboard. Uses edge detection
  (previous ref) so a persistently present tag doesn't block navigation
  to other pages. Also wakes the screen if the display was blanked.
maziggy 5 месяцев назад
Родитель
Сommit
57a774c32f

+ 4 - 2
frontend/src/components/spoolbuddy/SpoolBuddyLayout.tsx

@@ -100,15 +100,17 @@ export function SpoolBuddyLayout() {
     };
   }, [resetActivity]);
 
-  // Auto-navigate to dashboard when a tag is detected on a non-dashboard page
+  // Auto-navigate to dashboard when a NEW tag is detected (transition from no-tag to tag)
   const tagDetected = Boolean(sbState.matchedSpool || sbState.unknownTagUid);
+  const prevTagDetected = useRef(false);
   useEffect(() => {
-    if (tagDetected) {
+    if (tagDetected && !prevTagDetected.current) {
       resetActivity();
       if (location.pathname !== '/spoolbuddy') {
         navigate('/spoolbuddy');
       }
     }
+    prevTagDetected.current = tagDetected;
   }, [tagDetected, location.pathname, navigate, resetActivity]);
 
   // Screen blank timer

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
static/assets/index-Bu1bGLqb.js


+ 1 - 1
static/index.html

@@ -23,7 +23,7 @@
 
     <!-- Splash screens for iOS -->
     <link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
-    <script type="module" crossorigin src="/assets/index-BruWyGaL.js"></script>
+    <script type="module" crossorigin src="/assets/index-Bu1bGLqb.js"></script>
     <link rel="stylesheet" crossorigin href="/assets/index-CZLTApPU.css">
   </head>
   <body>

Некоторые файлы не были показаны из-за большого количества измененных файлов