From ba9cb2c39cae95a32e90a835dba38718111f18e1 Mon Sep 17 00:00:00 2001 From: Parikshith Mohite Date: Sun, 29 Sep 2024 14:27:35 -0400 Subject: [PATCH] Add functionality to metric settings buttons --- src/components/NowPlaying.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/NowPlaying.tsx b/src/components/NowPlaying.tsx index d4ead14..7c342ee 100644 --- a/src/components/NowPlaying.tsx +++ b/src/components/NowPlaying.tsx @@ -75,6 +75,19 @@ class NowPlaying extends React.Component<{}, {audioFeatures: AudioFeaturesRespon } }; + toggleMetric = (metric: string) => { + if (this.state.metricsToDisplay.includes(metric)) { + this.setState({ + metricsToDisplay: this.state.metricsToDisplay.filter((val) => val != metric) + }, this.setSongMetrics); + } + else { + this.setState({ + metricsToDisplay: [...this.state.metricsToDisplay, metric] + }, this.setSongMetrics); + } + } + render() { Spicetify.Player.addEventListener("songchange", this.setAudioFeatures); @@ -162,7 +175,7 @@ class NowPlaying extends React.Component<{}, {audioFeatures: AudioFeaturesRespon })} -
+
{"Displayed statistics: "} {allMetrics.map((metric: string, i) => { - return + return })} {/*