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"}*//
var SpotifyControls = (_ => {
var _this;
var _this, insertPatchCancel;
var controls, lastSong, currentVolume, lastVolume, stopTime, previousIsClicked, previousDoubleTimeout, timelineTimeout, timelineDragging, updateInterval;
var playbackState = {};
var settings = {};
@ -353,8 +353,8 @@ var SpotifyControls = (_ => {
};
this.patchedModules = {
after: {
AnalyticsContext: "render"
before: {
AppView: "render"
}
};
}
@ -616,6 +616,8 @@ var SpotifyControls = (_ => {
this.forceUpdateAll();
if (typeof insertPatchCancel == "function") insertPatchCancel();
BDFDB.PluginUtils.clear(this);
}
}
@ -630,20 +632,16 @@ var SpotifyControls = (_ => {
}
}
processAnalyticsContext (e) {
if (typeof e.returnvalue.props.children == "function" && e.instance.props.section == BDFDB.DiscordConstants.AnalyticsSections.ACCOUNT_PANEL) {
let renderChildren = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
return [
BDFDB.ReactUtils.createElement(SpotifyControlsComponent, {
processAppView (e) {
if (typeof insertPatchCancel == "function") insertPatchCancel();
insertPatchCancel = BDFDB.ModuleUtils.patch(this, e.instance, "renderChannelSidebar", {after: e2 => {
let [children, index] = BDFDB.ReactUtils.findParent(e2.returnValue, {props: [["section", BDFDB.DiscordConstants.AnalyticsSections.ACCOUNT_PANEL]]});
if (index > -1) children.splice(index - 1, 0, BDFDB.ReactUtils.createElement(SpotifyControlsComponent, {
song: BDFDB.LibraryModules.SpotifyTrackUtils.getActivity(false),
maximized: BDFDB.DataUtils.load(this, "playerState", "maximized"),
timeline: settings.addTimeline
}),
renderChildren(...args)
];
};
}
}));
}}, {force: true, noCache: true});
}
updatePlayer (song) {