Update ServerFolders.plugin.js
This commit is contained in:
parent
e6504fc246
commit
47c695b7e2
|
@ -14,7 +14,9 @@
|
|||
|
||||
module.exports = (_ => {
|
||||
const changeLog = {
|
||||
|
||||
"fixed": {
|
||||
"Scrolling": "Scrolling while extra column disabled works again"
|
||||
}
|
||||
};
|
||||
|
||||
return !window.BDFDB_Global || (!window.BDFDB_Global.loaded && !window.BDFDB_Global.started) ? class {
|
||||
|
@ -94,6 +96,9 @@ module.exports = (_ => {
|
|||
this.props.closing = true;
|
||||
BDFDB.ReactUtils.forceUpdate(this);
|
||||
}, 300);
|
||||
|
||||
BDFDB.DOMUtils.toggleClass(document.body, BDFDB.disCN._serverfoldersfoldercontentisopen, !(!folders.length || closing));
|
||||
|
||||
return BDFDB.ReactUtils.createElement("nav", {
|
||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.guildswrapper, BDFDB.disCN.guilds, this.props.isAppFullscreen && BDFDB.disCN.guildswrapperhidden, this.props.themeOverride && BDFDB.disCN.themedark, BDFDB.disCN._serverfoldersfoldercontent, (!folders.length || closing) && BDFDB.disCN._serverfoldersfoldercontentclosed),
|
||||
children: BDFDB.ReactUtils.createElement("ul", {
|
||||
|
@ -106,7 +111,7 @@ module.exports = (_ => {
|
|||
children: GuildItemWrapperComponent && this.props.folders.map(folder => {
|
||||
let data = _this.getFolderConfig(folder.folderId);
|
||||
let folderIcon = null;
|
||||
if (_this.settings.addFolderIcon) {
|
||||
if (_this.settings.general.addFolderIcon) {
|
||||
let folderIcons = _this.loadAllIcons();
|
||||
folderIcon = folderIcons[data.iconID] ? (!folderIcons[data.iconID].customID ? _this.createBase64SVG(folderIcons[data.iconID].openicon, data.color1, data.color2) : folderIcons[data.iconID].openicon) : null;
|
||||
folderIcon = folderIcon ? BDFDB.ReactUtils.createElement("div", {
|
||||
|
@ -120,15 +125,13 @@ module.exports = (_ => {
|
|||
return [
|
||||
folderIcon && BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.guildouter,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildComponents.BlobMask, {
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Clickable, {
|
||||
className: BDFDB.disCN.guildfolder,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.guildfolder,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.guildfoldericonwrapper,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.guildfoldericonwrapper,
|
||||
children: BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.guildfoldericonwrapperexpanded,
|
||||
children: folderIcon
|
||||
})
|
||||
className: BDFDB.disCN.guildfoldericonwrapperexpanded,
|
||||
children: folderIcon
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -444,14 +447,16 @@ module.exports = (_ => {
|
|||
|
||||
this.modulePatches = {
|
||||
before: [
|
||||
"GuildItemWrapper"
|
||||
"FolderItem",
|
||||
"GuildItemWrapper",
|
||||
"GuildsBar"
|
||||
],
|
||||
after: [
|
||||
"FolderHeader",
|
||||
"FolderItem",
|
||||
"FolderSettingsModal",
|
||||
"GuildItem",
|
||||
"GuildsBar",
|
||||
"ListItemTooltip"
|
||||
],
|
||||
componentDidMount: [
|
||||
"FolderSettingsModal"
|
||||
|
@ -508,12 +513,19 @@ module.exports = (_ => {
|
|||
opacity: 0.5 !important;
|
||||
z-index: 10000 !important;
|
||||
}
|
||||
${BDFDB.dotCNS._serverfoldershassidebar + BDFDB.dotCN.guildfolderexpandedbackground} {
|
||||
display: none !important;
|
||||
}
|
||||
${BDFDB.dotCN._serverfoldersfoldercontent + BDFDB.notCN.guildswrapperhidden} {
|
||||
transition: width 0.2s cubic-bezier(.44,1.04,1,1.01) !important;
|
||||
}
|
||||
${BDFDB.dotCN._serverfoldersfoldercontent + BDFDB.dotCN._serverfoldersfoldercontentclosed} {
|
||||
width: 0 !important;
|
||||
}
|
||||
${BDFDB.dotCNS._serverfoldersfoldercontent + BDFDB.dotCN.guildfolder} {
|
||||
cursor: default;
|
||||
border-radius: 100%;
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
|
@ -681,7 +693,9 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
processGuildsBar (e) {
|
||||
if (this.settings.general.extraColumn) {
|
||||
if (!this.settings.general.extraColumn) return;
|
||||
if (!e.returnvalue) e.instance.props.className = BDFDB.DOMUtils.formatClassName(e.instance.props.className, BDFDB.disCN._serverfoldershassidebar);
|
||||
else {
|
||||
let fullscreen = BDFDB.LibraryStores.ChannelRTCStore.isFullscreenInContext();
|
||||
if (folderGuildContent && (fullscreen != folderGuildContent.props.isAppFullscreen || e.instance.props.themeOverride != folderGuildContent.props.themeOverride)) {
|
||||
folderGuildContent.props.isAppFullscreen = fullscreen;
|
||||
|
@ -718,11 +732,9 @@ module.exports = (_ => {
|
|||
|
||||
processFolderItem (e) {
|
||||
if (!e.instance.props.folderNode) return;
|
||||
let expandedFolders = BDFDB.LibraryStores.ExpandedGuildFolderStore.getExpandedFolders();
|
||||
if (expandedFolders.size) BDFDB.DOMUtils.addClass(document.body, BDFDB.disCN._serverfoldersfoldercontentisopen);
|
||||
else BDFDB.DOMUtils.removeClassFromDOM(BDFDB.disCN._serverfoldersfoldercontentisopen);
|
||||
|
||||
let data = this.getFolderConfig(e.instance.props.folderNode.id);
|
||||
|
||||
if (data.muteFolder) for (let guildId of e.instance.props.folderNode.children.map(n => n.id)) if (!BDFDB.LibraryStores.UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(guildId)) BDFDB.LibraryModules.GuildNotificationsUtils.updateGuildNotificationSettings(guildId, {muted: true, suppress_everyone: true});
|
||||
|
||||
let state = this.getState(e.instance);
|
||||
|
@ -737,30 +749,17 @@ module.exports = (_ => {
|
|||
}
|
||||
folderStates[e.instance.props.folderNode.id] = state;
|
||||
|
||||
let [tooltipParent, tooltipIndex] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: ["ListItemTooltip", "BDFDB_TooltipContainer"]});
|
||||
if (tooltipIndex > -1) tooltipParent[tooltipIndex] = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: e.instance.props.folderNode.name || e.instance.props.defaultFolderName,
|
||||
tooltipConfig: {
|
||||
type: "right",
|
||||
list: true,
|
||||
offset: 12,
|
||||
backgroundColor: data.color3,
|
||||
fontColor: data.color4
|
||||
},
|
||||
children: tooltipParent[tooltipIndex].props.children
|
||||
e.instance.props.folderNode = Object.assign({}, e.instance.props.folderNode, {
|
||||
_childCount: e.instance.props.folderNode.children.length,
|
||||
children: this.settings.general.extraColumn ? [] : e.instance.props.folderNode.children
|
||||
});
|
||||
if (this.settings.general.extraColumn) {
|
||||
e.returnvalue.props.children[0] = null;
|
||||
e.returnvalue.props.children[2] = BDFDB.ReactUtils.createElement("div", {
|
||||
children: e.returnvalue.props.children[2],
|
||||
style: {display: "none"}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
processFolderHeader (e) {
|
||||
if (!e.instance.props.folderNode) return;
|
||||
|
||||
let data = this.getFolderConfig(e.instance.props.folderNode.id);
|
||||
|
||||
if (e.instance.props.expanded || data.useCloseIcon) {
|
||||
let folderIcons = this.loadAllIcons(), iconType = e.instance.props.expanded ? "openicon" : "closedicon";
|
||||
let icon = folderIcons[data.iconID] ? (!folderIcons[data.iconID].customID ? this.createBase64SVG(folderIcons[data.iconID][iconType], data.color1, data.color2) : folderIcons[data.iconID][iconType]) : null;
|
||||
|
@ -775,15 +774,34 @@ module.exports = (_ => {
|
|||
if (this.settings.general.showCountBadge) {
|
||||
let mask = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "BlobMask"});
|
||||
if (mask) {
|
||||
mask.props.upperLeftBadgeWidth = BDFDB.LibraryComponents.Badges.NumberBadge.prototype.getBadgeWidthForValue(e.instance.props.folderNode.children.length);
|
||||
mask.props.upperLeftBadgeWidth = BDFDB.LibraryComponents.Badges.NumberBadge.prototype.getBadgeWidthForValue(e.instance.props.folderNode._childCount);
|
||||
mask.props.upperLeftBadge = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, {
|
||||
count: e.instance.props.folderNode.children.length,
|
||||
count: e.instance.props.folderNode._childCount,
|
||||
style: {backgroundColor: "var(--bdfdb-blurple)"}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processListItemTooltip (e) {
|
||||
let folderNodeChild = BDFDB.ReactUtils.findChild(e.instance, {filter: n => n && n.props && n.props.folderNode});
|
||||
if (!folderNodeChild) return;
|
||||
|
||||
let data = this.getFolderConfig(folderNodeChild.props.folderNode.id);
|
||||
|
||||
e.returnvalue = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
||||
text: folderNodeChild.props.folderNode.name || folderNodeChild.props.tooltipName,
|
||||
tooltipConfig: {
|
||||
type: "right",
|
||||
list: true,
|
||||
offset: 12,
|
||||
backgroundColor: data.color3,
|
||||
fontColor: data.color4
|
||||
},
|
||||
children: e.returnvalue.props.children
|
||||
});
|
||||
}
|
||||
|
||||
processGuildItemWrapper (e) {
|
||||
if (e.component) GuildItemWrapperComponent = e.component;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue