users can select each button now (simple additions can be made with url attribute in preload and store option.
Signed-off-by: Core <core@coredev.uk>
This commit is contained in:
parent
388759adba
commit
6ee309a6c5
1 changed files with 30 additions and 9 deletions
|
@ -204,8 +204,8 @@ export default class DiscordRPC {
|
||||||
|
|
||||||
// Check if show buttons is (true) or (false)
|
// Check if show buttons is (true) or (false)
|
||||||
let activity: Object = {
|
let activity: Object = {
|
||||||
details: this._utils.getStoreValue("connectivity.discord_rpc.details_format"),
|
details: this._utils.getStoreValue("connectivity.discord_rpc.activity.details_format"),
|
||||||
state: this._utils.getStoreValue("connectivity.discord_rpc.state_format"),
|
state: this._utils.getStoreValue("connectivity.discord_rpc.activity.state_format"),
|
||||||
largeImageKey: attributes?.artwork?.url?.replace("{w}", "1024").replace("{h}", "1024"),
|
largeImageKey: attributes?.artwork?.url?.replace("{w}", "1024").replace("{h}", "1024"),
|
||||||
largeImageText: attributes.albumName,
|
largeImageText: attributes.albumName,
|
||||||
instance: false, // Whether the activity is in a game session
|
instance: false, // Whether the activity is in a game session
|
||||||
|
@ -232,13 +232,34 @@ export default class DiscordRPC {
|
||||||
* Filter the Discord activity object
|
* Filter the Discord activity object
|
||||||
*/
|
*/
|
||||||
private filterActivity(activity: any, attributes: any): Object {
|
private filterActivity(activity: any, attributes: any): Object {
|
||||||
// Add the buttons if people want them
|
|
||||||
const showSongLink = this._utils.getStoreValue("connectivity.discord_rpc.show_songlink");
|
// Handling Activity Buttons
|
||||||
if (!this._utils.getStoreValue("connectivity.discord_rpc.hide_buttons")) {
|
if (this._utils.getStoreValue("connectivity.discord_rpc.activity.buttons.enabled") && this._utils.getStoreValue("connectivity.discord_rpc.activity.buttons.first") != "disabled") {
|
||||||
activity.buttons = [
|
const activityUrls: { [key: string]: any } = {
|
||||||
{ label: "Listen on Cider", url: attributes.url.cider },
|
"listenOnCider": "cider",
|
||||||
...(showSongLink ? [{ label: "View on other platforms", url: "https://song.link/i/" + attributes.songId }] : [{ label: "View on Apple Music", url: attributes.url.appleMusic }]),
|
"viewOnAppleMusic": "appleMusic",
|
||||||
]; //To change attributes.url => preload/cider-preload.js
|
"viewOnOtherMusicServices": "songLink"
|
||||||
|
}
|
||||||
|
|
||||||
|
const firstActivity = {"label": this._utils.getLocale(this._utils.getStoreValue("general.language"), `settings.option.connectivity.discordRPC.buttons.${this._utils.getStoreValue("connectivity.discord_rpc.activity.buttons.first")}`), "url": activityUrls[this._utils.getStoreValue("connectivity.discord_rpc.activity.buttons.first")]}
|
||||||
|
const secondActivity = {"label": this._utils.getLocale(this._utils.getStoreValue("general.language"), `settings.option.connectivity.discordRPC.buttons.${this._utils.getStoreValue("connectivity.discord_rpc.activity.buttons.second")}`), "url": activityUrls[this._utils.getStoreValue("connectivity.discord_rpc.activity.buttons.second")]}
|
||||||
|
|
||||||
|
if (this._utils.getStoreValue("connectivity.discord_rpc.activity.buttons.second") != "disabled") {
|
||||||
|
activity.buttons = [
|
||||||
|
{"label": firstActivity.label, "url": attributes.url[firstActivity.url]},
|
||||||
|
{"label": secondActivity.label, "url": attributes.url[secondActivity.url]}
|
||||||
|
]
|
||||||
|
console.log(secondActivity)
|
||||||
|
console.log("Its not disabled")
|
||||||
|
} else {
|
||||||
|
activity.buttons = [
|
||||||
|
{"label": firstActivity.label, "url": attributes.url[firstActivity.url]}
|
||||||
|
]
|
||||||
|
console.log("Its disabled")
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("LOOK HERELOOK HERELOOK HERELOOK HERELOOK HERELOOK HERELOOK HERE")
|
||||||
|
console.log(activity.buttons)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the timestamp if its playing and people want them
|
// Add the timestamp if its playing and people want them
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue