Update DisplayServersAsChannels.plugin.js

This commit is contained in:
Mirco Wittrien 2024-09-05 14:25:28 +02:00
parent d604494098
commit d21a386469
1 changed files with 30 additions and 18 deletions

View File

@ -2,7 +2,7 @@
* @name DisplayServersAsChannels * @name DisplayServersAsChannels
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.7.7 * @version 1.7.8
* @description Displays Servers in a similar way as Channels * @description Displays Servers in a similar way as Channels
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -167,24 +167,36 @@ module.exports = (_ => {
} }
processGuildsBar (e) { processGuildsBar (e) {
let scroller = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.guildsscroller]]}); const process = returnValue => {
if (scroller) { let scroller = BDFDB.ReactUtils.findChild(returnValue, {props: [["className", BDFDB.disCN.guildsscroller]]});
scroller.props.fade = true; if (scroller) {
let padding = parseInt(BDFDB.LibraryModules.PlatformUtils.isWindows() ? 4 : BDFDB.LibraryModules.PlatformUtils.isDarwin() ? 0 : 12) + 10; scroller.props.fade = true;
let isVisible = (currentItem, t, items) => { let padding = parseInt(BDFDB.LibraryModules.PlatformUtils.isWindows() ? 4 : BDFDB.LibraryModules.PlatformUtils.isDarwin() ? 0 : 12) + 10;
if (!scroller.ref || !scroller.ref.current) return false; let isVisible = (currentItem, t, items) => {
const index = items.findIndex(item => typeof item == "string" || !item ? currentItem === item : item.includes(currentItem)); if (!scroller.ref || !scroller.ref.current) return false;
if (index < 0) return false; const index = items.findIndex(item => typeof item == "string" || !item ? currentItem === item : item.includes(currentItem));
let size = this.settings.amounts.serverElementHeight * index + padding; if (index < 0) return false;
if (!t) size += 40; let size = this.settings.amounts.serverElementHeight * index + padding;
const state = typeof scroller.ref.current.getScrollerState == "function" ? scroller.ref.current.getScrollerState() : Node.prototype.isPrototypeOf(scroller.ref.current) ? scroller.ref.current : {}; if (!t) size += 40;
return !!(!t && size >= state.scrollTop || t && size + parseInt(this.settings.amounts.serverElementHeight) <= state.scrollTop + state.offsetHeight); const state = typeof scroller.ref.current.getScrollerState == "function" ? scroller.ref.current.getScrollerState() : Node.prototype.isPrototypeOf(scroller.ref.current) ? scroller.ref.current : {};
}; return !!(!t && size >= state.scrollTop || t && size + parseInt(this.settings.amounts.serverElementHeight) <= state.scrollTop + state.offsetHeight);
let topBar = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.guildswrapperunreadmentionsbartop]]}); };
if (topBar) topBar.props.isVisible = BDFDB.TimeUtils.suppress(isVisible, "Error in isVisible of Top Bar in Guild List!"); let topBar = BDFDB.ReactUtils.findChild(returnValue, {props: [["className", BDFDB.disCN.guildswrapperunreadmentionsbartop]]});
let bottomBar = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.guildswrapperunreadmentionsbarbottom]]}); if (topBar) topBar.props.isVisible = BDFDB.TimeUtils.suppress(isVisible, "Error in isVisible of Top Bar in Guild List!");
if (bottomBar) bottomBar.props.isVisible = BDFDB.TimeUtils.suppress(isVisible, "Error in isVisible of Bottom Bar in Guild List!"); let bottomBar = BDFDB.ReactUtils.findChild(returnValue, {props: [["className", BDFDB.disCN.guildswrapperunreadmentionsbarbottom]]});
if (bottomBar) bottomBar.props.isVisible = BDFDB.TimeUtils.suppress(isVisible, "Error in isVisible of Bottom Bar in Guild List!");
}
};
let themeWrapper = BDFDB.ReactUtils.findChild(e.returnvalue, {filter: n => n && n.props && typeof n.props.children == "function"});
if (themeWrapper) {
let childrenRender = themeWrapper.props.children;
themeWrapper.props.children = BDFDB.TimeUtils.suppress((...args) => {
let children = childrenRender(...args);
process(children);
return children;
}, "Error in Children Render of Theme Wrapper!", this);
} }
else process(e.returnvalue);
} }
processHomeButtonDefault (e) { processHomeButtonDefault (e) {