fix: disk usage state and cava bar count
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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} />
|
||||
|
||||
Reference in New Issue
Block a user