fix: disk usage state and cava bar count

This commit is contained in:
Pihkaal
2024-08-22 18:26:15 +02:00
parent dd6c5faa5a
commit e7c405ca1d
3 changed files with 7 additions and 5 deletions

View File

@@ -66,7 +66,7 @@ const InnerCava = (props: InnerKittyProps<typeof Cava>) => {
const analyserRef = useRef<AnalyserNode | null>(null);
const audioContextRef = useRef<AudioContext | null>(null);
const [barHeights, setBarHeights] = useState(
new Array<number>(Math.round(props.cols / 3)).fill(0),
new Array<number>(Math.floor(props.cols / 3)).fill(0),
);
const requestRef = useRef<number>();
@@ -77,7 +77,7 @@ const InnerCava = (props: InnerKittyProps<typeof Cava>) => {
const dataArray = new Uint8Array(bufferLength);
analyserRef.current.getByteFrequencyData(dataArray);
const barCount = Math.round(props.cols / 3);
const barCount = Math.floor(props.cols / 3);
const newBarHeights = [];
for (let i = 0; i < barCount; i++) {

View File

@@ -1,3 +1,4 @@
import { useState } from "react";
import { WaybarWidget } from "../WaybarWidget";
import { randomMinMax } from "~/utils/math";
@@ -8,8 +9,9 @@ export const WaybarDiskWidget = (props: {
variation: number;
capacity: number;
}) => {
const value =
props.current + randomMinMax(-props.variation, props.variation + 1);
const [value] = useState(
props.current + randomMinMax(-props.variation, props.variation + 1),
);
const usage = Math.round((value / props.capacity) * 100);
return (

View File

@@ -43,7 +43,7 @@ export const Waybar = () => {
frequency={5000 + randomMinMax(-100, 100)}
min={18}
max={40}
start={randomMinMax(20, 30)}
start={1 + randomMinMax(20, 30)}
capacity={16}
/>
<WaybarDiskWidget current={35.9} variation={4.1} capacity={160.3} />