This commit is contained in:
Mirco Wittrien 2021-03-01 10:37:57 +01:00
parent 33c1fdec83
commit bea8f6a41a
2 changed files with 183 additions and 5 deletions

View File

@ -4626,6 +4626,16 @@ module.exports = (_ => {
};
InternalComponents.LibraryComponents.Badges = Object.assign({}, BDFDB.ModuleUtils.findByProperties("IconBadge", "NumberBadge"));
InternalComponents.LibraryComponents.Badges.getBadgePaddingForValue = function (count) {
switch (count) {
case 1:
case 4:
case 6:
return 1;
default:
return 0;
}
};
InternalComponents.LibraryComponents.Badges.IconBadge = reactInitialized && class BDFDB_IconBadge extends LibraryModules.React.Component {
render() {
return BDFDB.ReactUtils.createElement("div", {
@ -4640,6 +4650,27 @@ module.exports = (_ => {
});
}
};
InternalComponents.LibraryComponents.Badges.NumberBadge = reactInitialized && class BDFDB_IconBadge extends LibraryModules.React.Component {
handleClick(e) {if (typeof this.props.onClick == "function") this.props.onClick(e, this);}
handleContextMenu(e) {if (typeof this.props.onContextMenu == "function") this.props.onContextMenu(e, this);}
handleMouseEnter(e) {if (typeof this.props.onMouseEnter == "function") this.props.onMouseEnter(e, this);}
handleMouseLeave(e) {if (typeof this.props.onMouseLeave == "function") this.props.onMouseLeave(e, this);}
render() {
return BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(this.props.className, BDFDB.disCN.badgenumberbadge),
style: Object.assign({
backgroundColor: !this.props.disableColor && (this.props.color || BDFDB.DiscordConstants.Colors.STATUS_RED),
width: InternalComponents.LibraryComponents.Badges.getBadgeWidthForValue(this.props.count),
paddingRight: InternalComponents.LibraryComponents.Badges.getBadgePaddingForValue(this.props.count)
}, this.props.style),
onClick: this.handleClick.bind(this),
onContextMenu: this.handleContextMenu.bind(this),
onMouseEnter: this.handleMouseEnter.bind(this),
onMouseLeave: this.handleMouseLeave.bind(this),
children: InternalComponents.LibraryComponents.Badges.getBadgeCountString(this.props.count)
});
}
};
InternalComponents.LibraryComponents.BotTag = reactInitialized && class BDFDB_BotTag extends LibraryModules.React.Component {
handleClick(e) {if (typeof this.props.onClick == "function") this.props.onClick(e, this);}
@ -7190,7 +7221,7 @@ module.exports = (_ => {
onHide: (tooltip, anker) => {
delete anker.BDFDBtooltipShown;
shown = false;
if (this.props.tooltipConfig && typeof this.props.tooltipConfig.onHide == "function") this.props.onHide(tooltip, anker);
if (this.props.tooltipConfig && typeof this.props.tooltipConfig.onHide == "function") this.props.tooltipConfig.onHide(tooltip, anker);
}
}));
if (typeof this.props.onMouseEnter == "function") this.props.onMouseEnter(e, this);

View File

@ -179,8 +179,8 @@ module.exports = (_ => {
newChildren.push(this.createBadge(BDFDB.LibraryModules.StatusMetaUtils.getOnlineFriendCount()));
break;
case "PENDING":
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.PENDING_INCOMING]));
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.PENDING_OUTGOING]));
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.PENDING_INCOMING], this.labels.incoming));
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.PENDING_OUTGOING], this.labels.outgoing));
break;
case "BLOCKED":
newChildren.push(this.createBadge(relationshipCount[BDFDB.DiscordConstants.RelationshipTypes.BLOCKED]));
@ -334,18 +334,165 @@ module.exports = (_ => {
}, true));
}
createBadge (amount) {
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, {
createBadge (amount, text) {
let badge = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Badges.NumberBadge, {
className: BDFDB.disCN.peoplesbadge,
count: amount,
style: {marginLeft: 6}
});
return text ? BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
text: text,
tooltipConfig: {
type: "bottom"
},
children: badge
}) : badge;
}
rerenderList () {
let selectedButton = document.querySelector(BDFDB.dotCNS.peoplestabbar + BDFDB.dotCN.settingsitemselected);
if (selectedButton) selectedButton.click();
}
setLabelsByLanguage () {
switch (BDFDB.LanguageUtils.getLanguage().id) {
case "bg": // Bulgarian
return {
incoming: "Входящи",
outgoing: "Изходящи"
};
case "da": // Danish
return {
incoming: "Indgående",
outgoing: "Udgående"
};
case "de": // German
return {
incoming: "Eingehend",
outgoing: "Ausgehend"
};
case "el": // Greek
return {
incoming: "Εισερχόμενος",
outgoing: "Εξερχόμενος"
};
case "es": // Spanish
return {
incoming: "Entrante",
outgoing: "Saliente"
};
case "fi": // Finnish
return {
incoming: "Saapuva",
outgoing: "Lähtevä"
};
case "fr": // French
return {
incoming: "Entrant",
outgoing: "Sortant"
};
case "hr": // Croatian
return {
incoming: "Dolazni",
outgoing: "Odlazni"
};
case "hu": // Hungarian
return {
incoming: "Beérkező",
outgoing: "Kimenő"
};
case "it": // Italian
return {
incoming: "In arrivo",
outgoing: "Estroverso"
};
case "ja": // Japanese
return {
incoming: "着信",
outgoing: "発信"
};
case "ko": // Korean
return {
incoming: "들어오는",
outgoing: "나가는"
};
case "lt": // Lithuanian
return {
incoming: "Gaunamasis",
outgoing: "Išeinantis"
};
case "nl": // Dutch
return {
incoming: "Inkomend",
outgoing: "Uitgaand"
};
case "no": // Norwegian
return {
incoming: "Innkommende",
outgoing: "Utgående"
};
case "pl": // Polish
return {
incoming: "Przychodzący",
outgoing: "Towarzyski"
};
case "pt-BR": // Portuguese (Brazil)
return {
incoming: "Entrada",
outgoing: "Extrovertido"
};
case "ro": // Romanian
return {
incoming: "Primite",
outgoing: "De ieșire"
};
case "ru": // Russian
return {
incoming: "Входящий",
outgoing: "Исходящий"
};
case "sv": // Swedish
return {
incoming: "Inkommande",
outgoing: "Utgående"
};
case "th": // Thai
return {
incoming: "ขาเข้า",
outgoing: "ขาออก"
};
case "tr": // Turkish
return {
incoming: "Gelen",
outgoing: "Dışa dönük"
};
case "uk": // Ukrainian
return {
incoming: "Вхідні",
outgoing: "Вихідний"
};
case "vi": // Vietnamese
return {
incoming: "Mới đến",
outgoing: "Hướng ngoaị"
};
case "zh-CN": // Chinese (China)
return {
incoming: "进来的",
outgoing: "外向"
};
case "zh-TW": // Chinese (Taiwan)
return {
incoming: "傳入",
outgoing: "外向"
};
default: // English
return {
incoming: "Incoming",
outgoing: "Outgoing"
};
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
})();