mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 21:53:04 -04:00
This commit is contained in:
parent
281e9caeff
commit
c989a9c7bd
1 changed files with 19 additions and 16 deletions
|
@ -35,9 +35,24 @@ function makeSpotifyIcon(enabled: boolean) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setSpotifyActivity(value: boolean) {
|
||||||
|
const { body } = await RestAPI.get({
|
||||||
|
url: Constants.Endpoints.CONNECTIONS
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!body) return;
|
||||||
|
const spotifyId = body.find(conn => conn.type === "spotify")?.id;
|
||||||
|
|
||||||
|
await RestAPI.patch({
|
||||||
|
url: Constants.Endpoints.CONNECTION("spotify", spotifyId),
|
||||||
|
body: {
|
||||||
|
show_activity: value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function SpotifyActivityToggleButton() {
|
function SpotifyActivityToggleButton() {
|
||||||
const { spotifyConnection } = settings.store;
|
const { spotifyConnection } = settings.store;
|
||||||
const setSpotifyConnection = value => settings.store.spotifyConnection = value;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
|
@ -48,20 +63,8 @@ function SpotifyActivityToggleButton() {
|
||||||
redGlow={!spotifyConnection}
|
redGlow={!spotifyConnection}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const newValue = !spotifyConnection;
|
const newValue = !spotifyConnection;
|
||||||
setSpotifyConnection(newValue);
|
settings.store.spotifyConnection = newValue;
|
||||||
|
setSpotifyActivity(newValue);
|
||||||
const { body } = await RestAPI.get({
|
|
||||||
url: Constants.Endpoints.CONNECTIONS
|
|
||||||
});
|
|
||||||
|
|
||||||
const spotifyId = body.find(conn => conn.type === "spotify")?.id;
|
|
||||||
|
|
||||||
await RestAPI.patch({
|
|
||||||
url: Constants.Endpoints.CONNECTION("spotify", spotifyId),
|
|
||||||
body: {
|
|
||||||
show_activity: newValue,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -72,7 +75,7 @@ const settings = definePluginSettings({
|
||||||
type: OptionType.BOOLEAN,
|
type: OptionType.BOOLEAN,
|
||||||
description: "Show Spotify activity",
|
description: "Show Spotify activity",
|
||||||
default: false,
|
default: false,
|
||||||
hidden: true
|
onChange: async value => setSpotifyActivity(value),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue