Update SpotifyControls.plugin.js

This commit is contained in:
Mirco Wittrien 2020-08-15 20:27:43 +02:00
parent e2192d2150
commit 4faa213876
1 changed files with 15 additions and 17 deletions

View File

@ -1,7 +1,7 @@
//META{"name":"SpotifyControls","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SpotifyControls","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SpotifyControls/SpotifyControls.plugin.js"}*// //META{"name":"SpotifyControls","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/SpotifyControls","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/SpotifyControls/SpotifyControls.plugin.js"}*//
var SpotifyControls = (_ => { var SpotifyControls = (_ => {
var _this; var _this, insertPatchCancel;
var controls, lastSong, currentVolume, lastVolume, stopTime, previousIsClicked, previousDoubleTimeout, timelineTimeout, timelineDragging, updateInterval; var controls, lastSong, currentVolume, lastVolume, stopTime, previousIsClicked, previousDoubleTimeout, timelineTimeout, timelineDragging, updateInterval;
var playbackState = {}; var playbackState = {};
var settings = {}; var settings = {};
@ -353,8 +353,8 @@ var SpotifyControls = (_ => {
}; };
this.patchedModules = { this.patchedModules = {
after: { before: {
AnalyticsContext: "render" AppView: "render"
} }
}; };
} }
@ -616,6 +616,8 @@ var SpotifyControls = (_ => {
this.forceUpdateAll(); this.forceUpdateAll();
if (typeof insertPatchCancel == "function") insertPatchCancel();
BDFDB.PluginUtils.clear(this); BDFDB.PluginUtils.clear(this);
} }
} }
@ -630,20 +632,16 @@ var SpotifyControls = (_ => {
} }
} }
processAnalyticsContext (e) { processAppView (e) {
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.ACCOUNT_PANEL) { if (typeof insertPatchCancel == "function") insertPatchCancel();
let renderChildren = e.returnvalue.props.children; insertPatchCancel = BDFDB.ModuleUtils.patch(this, e.instance, "renderChannelSidebar", {after: e2 => {
e.returnvalue.props.children = (...args) => { let [children, index] = BDFDB.ReactUtils.findParent(e2.returnValue, {props: [["section", BDFDB.DiscordConstants.AnalyticsSections.ACCOUNT_PANEL]]});
return [ if (index > -1) children.splice(index - 1, 0, BDFDB.ReactUtils.createElement(SpotifyControlsComponent, {
BDFDB.ReactUtils.createElement(SpotifyControlsComponent, {
song: BDFDB.LibraryModules.SpotifyTrackUtils.getActivity(false), song: BDFDB.LibraryModules.SpotifyTrackUtils.getActivity(false),
maximized: BDFDB.DataUtils.load(this, "playerState", "maximized"), maximized: BDFDB.DataUtils.load(this, "playerState", "maximized"),
timeline: settings.addTimeline timeline: settings.addTimeline
}), }));
renderChildren(...args) }}, {force: true, noCache: true});
];
};
}
} }
updatePlayer (song) { updatePlayer (song) {