fixed sen5x status component not rotating after switching setting
This commit is contained in:
parent
c19974edd9
commit
2a578a947e
1 changed files with 10 additions and 6 deletions
|
|
@ -52,7 +52,7 @@ const useStyles = makeStyles((theme: Theme) => {
|
||||||
export default function StatusPlenum(props: Props) {
|
export default function StatusPlenum(props: Props) {
|
||||||
const { device, noDust } = props;
|
const { device, noDust } = props;
|
||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
// console.log(noDust)
|
||||||
const colors = or(device.status.sen5x?.overlays.map(overlay => overlay.color), []);
|
const colors = or(device.status.sen5x?.overlays.map(overlay => overlay.color), []);
|
||||||
const messages = or(device.status.sen5x?.overlays.map(overlay => overlay.message), []);
|
const messages = or(device.status.sen5x?.overlays.map(overlay => overlay.message), []);
|
||||||
|
|
||||||
|
|
@ -73,15 +73,19 @@ export default function StatusPlenum(props: Props) {
|
||||||
|
|
||||||
const [currentIndex, setCurrentIndex] = useState(0);
|
const [currentIndex, setCurrentIndex] = useState(0);
|
||||||
|
|
||||||
// Auto-cycle through measurements every 3 seconds
|
// Auto-cycle through measurements every 5 seconds
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (noDust) return
|
if (noDust) {
|
||||||
|
setCurrentIndex(0)
|
||||||
|
return
|
||||||
|
}
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
setCurrentIndex((prevIndex) => (prevIndex + 1) % 2);
|
console.log(noDust)
|
||||||
}, 3000); // Adjust timing as needed (3000ms = 3s)
|
if (!noDust) setCurrentIndex((prevIndex) => (prevIndex + 1) % 2);
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
return () => clearInterval(interval); // Cleanup on unmount
|
return () => clearInterval(interval); // Cleanup on unmount
|
||||||
}, []);
|
}, [noDust]);
|
||||||
|
|
||||||
const tooltip = () => {
|
const tooltip = () => {
|
||||||
if (messages.length === 0) return null
|
if (messages.length === 0) return null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue