mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-21 10:15:04 +02:00
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user