Update PinDMs.plugin.js
This commit is contained in:
parent
6dee747d77
commit
54c7fcc51f
|
@ -19,7 +19,7 @@ class PinDMs {
|
||||||
|
|
||||||
getDescription () {return "Allows you to pin DMs, making them appear at the top of your DM-list.";}
|
getDescription () {return "Allows you to pin DMs, making them appear at the top of your DM-list.";}
|
||||||
|
|
||||||
getVersion () {return "1.1.9";}
|
getVersion () {return "1.2.0";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ class PinDMs {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {this.onSwitch();},1000);
|
setTimeout(() => {this.patchDMsScroller();},1000);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
|
console.error(this.getName() + ": Fatal Error: Could not load BD functions!");
|
||||||
|
@ -110,12 +110,6 @@ class PinDMs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSwitch () {
|
|
||||||
if (!document.querySelector(BDFDB.dotCNS.guildselected + BDFDB.dotCN.friendsicon)) return;
|
|
||||||
|
|
||||||
this.patchDMsScroller();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// begin of own functions
|
// begin of own functions
|
||||||
|
|
||||||
|
@ -177,9 +171,6 @@ class PinDMs {
|
||||||
}
|
}
|
||||||
|
|
||||||
patchDMsScroller () {
|
patchDMsScroller () {
|
||||||
let dmsscroller = document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller);
|
|
||||||
if (dmsscroller) {
|
|
||||||
if (!this.lazyScrollerWasPatched) {
|
|
||||||
let addAllDMs = (dmsarray) => {
|
let addAllDMs = (dmsarray) => {
|
||||||
let sortedDMs = this.sortAndUpdate();
|
let sortedDMs = this.sortAndUpdate();
|
||||||
if (sortedDMs.length > 0) {
|
if (sortedDMs.length > 0) {
|
||||||
|
@ -187,25 +178,18 @@ class PinDMs {
|
||||||
for (let pos in sortedDMs) this.addPinnedDM(sortedDMs[pos], dmsarray, insertpoint);
|
for (let pos in sortedDMs) this.addPinnedDM(sortedDMs[pos], dmsarray, insertpoint);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.lazyScrollerWasPatched = true;
|
this.patchCancels.push(BDFDB.WebModules.monkeyPatch(BDFDB.WebModules.findByName("LazyScroller").prototype, "render", {before: (e) => {
|
||||||
let lazyScrollerDMsInstance = BDFDB.getOwnerInstance({"node":dmsscroller, "props":["createComputer","getSubscriptions"], "up":true});
|
if (e.thisObject._reactInternalFiber.return.memoizedProps.privateChannelIds && !e.thisObject.props.PinDMsPatched) {
|
||||||
let lazyScrollerDMsWrap = lazyScrollerDMsInstance._reactInternalFiber.type;
|
e.thisObject.props.PinDMsPatched = true;
|
||||||
this.patchCancels.push(BDFDB.WebModules.monkeyPatch(lazyScrollerDMsWrap.prototype, "componentDidMount", {before: (e) => {
|
|
||||||
e.thisObject.props.patched = true;
|
|
||||||
addAllDMs(e.thisObject.props.children);
|
addAllDMs(e.thisObject.props.children);
|
||||||
}}));
|
|
||||||
this.patchCancels.push(BDFDB.WebModules.monkeyPatch(lazyScrollerDMsWrap.prototype, "componentDidUpdate", {before: (e) => {
|
|
||||||
if (!e.thisObject.props.patched) {
|
|
||||||
e.thisObject.props.patched = true;
|
|
||||||
addAllDMs(e.thisObject.props.children);
|
|
||||||
this.forceUpdateScroller(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
|
|
||||||
}
|
}
|
||||||
}}));
|
}}));
|
||||||
|
let dmsscroller = document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller);
|
||||||
|
if (dmsscroller) {
|
||||||
addAllDMs(BDFDB.getReactInstance(dmsscroller).return.return.return.memoizedProps.children);
|
addAllDMs(BDFDB.getReactInstance(dmsscroller).return.return.return.memoizedProps.children);
|
||||||
this.forceUpdateScroller(dmsscroller);
|
this.forceUpdateScroller(dmsscroller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
getInsertPoint (dms) {
|
getInsertPoint (dms) {
|
||||||
let insertpoint = null;
|
let insertpoint = null;
|
||||||
|
|
Loading…
Reference in New Issue