This commit is contained in:
Mirco Wittrien 2022-10-28 13:04:56 +02:00
parent f3366594bb
commit dcff64e2e6
2 changed files with 111 additions and 98 deletions

View File

@ -400,6 +400,13 @@
"NowPlayingItem": {"strings": [".wrapper", "padded:"]}, "NowPlayingItem": {"strings": [".wrapper", "padded:"]},
"PanelButton": {"strings": ["Masks.PANEL_BUTTON"]}, "PanelButton": {"strings": ["Masks.PANEL_BUTTON"]},
"ParticipantsForSelectedParticipant": {"strings": ["ACTIVITY", "maxVisibleUsers", "participantType"]}, "ParticipantsForSelectedParticipant": {"strings": ["ACTIVITY", "maxVisibleUsers", "participantType"]},
"PeopleList": {"strings": [".SECTION_NO_RESULTS", ".section", "SUGGESTIONS"]},
"PeopleListItem": {"strings": ["height:new", "isFocused", "onOtherHover"]},
"PeopleListItemBlocked": {"strings": [".listItemContents", "UNKNOWN", ".BLOCKED"]},
"PeopleListItemFriend": {"strings": [".getMutablePrivateChannels", ".handleOpenPrivateChannel", "isActiveRow"]},
"PeopleListItemPending": {"strings": ["PENDING_INCOMING", ".DENY", "addRelationship"]},
"PeopleListSectionedLazy": {"strings": [".statusSections", ".peopleList", "id:\"people-list\""]},
"PeopleListSectionedNonLazy": {"strings": [".statusSections", ".peopleList", "id:\"people\""]},
"PrivateChannel": {"strings": ["LEAVE_GROUP_DM_MANAGED_BODY", "handleCloseButtonMouseDown", "handleLeaveGroup"]}, "PrivateChannel": {"strings": ["LEAVE_GROUP_DM_MANAGED_BODY", "handleCloseButtonMouseDown", "handleLeaveGroup"]},
"PrivateChannelRecipients": {"strings": [".membersWrap", "recipients"]}, "PrivateChannelRecipients": {"strings": [".membersWrap", "recipients"]},
"PrivateChannelsList": {"strings": ["privateChannelIds", "privateChannelRecipientsInviteButtonIcon"]}, "PrivateChannelsList": {"strings": ["privateChannelIds", "privateChannelRecipientsInviteButtonIcon"]},
@ -419,6 +426,7 @@
"Spoiler": {"strings": ["revealSpoiler", ".onReveal"]}, "Spoiler": {"strings": ["revealSpoiler", ".onReveal"]},
"SpoilerWarning": {"strings": [".spoilerWarning", ".SPOILER"]}, "SpoilerWarning": {"strings": [".spoilerWarning", ".SPOILER"]},
"StandardSidebarView": {"strings": ["standardSidebarView", ".sidebarTheme", "mobileSidebarHeader"]}, "StandardSidebarView": {"strings": ["standardSidebarView", ".sidebarTheme", "mobileSidebarHeader"]},
"TabBar": {"props": ["Types", "Looks", "Item", "Panel"]},
"TransitionGroup": {"protos": ["performAppear", "performEnter", "performLeave"]}, "TransitionGroup": {"protos": ["performAppear", "performEnter", "performLeave"]},
"UnreadDMs": {"strings": ["getMutablePrivateChannels", "selectedVoiceGuildId", ".selectedVoiceChannelId"]}, "UnreadDMs": {"strings": ["getMutablePrivateChannels", "selectedVoiceGuildId", ".selectedVoiceChannelId"]},
"UseCopyIdItem": {"strings": ["\"devmode-copy-id\""]}, "UseCopyIdItem": {"strings": ["\"devmode-copy-id\""]},

View File

@ -2,7 +2,7 @@
* @name BetterFriendList * @name BetterFriendList
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.4.6 * @version 1.4.7
* @description Adds extra Controls to the Friends Page, for example sort by Name/Status, Search and All/Request/Blocked Amount * @description Adds extra Controls to the Friends Page, for example sort by Name/Status, Search and All/Request/Blocked Amount
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -87,22 +87,28 @@ module.exports = (_ => {
} }
}; };
this.patchedModules = { this.modulePatches = {
before: { before: [
TabBar: "render", "PeopleListSectionedLazy",
PeopleListSectionedLazy: "default", "PeopleListSectionedNonLazy",
PeopleListSectionedNonLazy: "default" "TabBar"
}, ],
after: { after: [
TabBar: "render", "PeopleList",
PeopleListSectionedLazy: "default", "PeopleListItem",
PeopleListSectionedNonLazy: "default", "PeopleListItemBlocked",
PeopleList: "default", "PeopleListItemFriend",
FriendRow: "render", "PeopleListItemPending",
PendingRow: "default", "PeopleListSectionedLazy",
BlockedRow: "render", "PeopleListSectionedNonLazy",
PeopleListItem: ["render", "componentDidMount","componentWillUnmount"] "TabBar"
} ],
componentDidMount: [
"PeopleListItem"
],
componentWillUnmount: [
"PeopleListItem"
]
}; };
this.css = ` this.css = `
@ -180,37 +186,37 @@ module.exports = (_ => {
} }
onUserContextMenu (e) { onUserContextMenu (e) {
if (e.instance.props.user && e.subType == "useUserRelationshipItems" && BDFDB.LibraryStores.RelationshipStore.isFriend(e.instance.props.user.id)) { if (!e.instance.props.user || !BDFDB.LibraryStores.RelationshipStore.isFriend(e.instance.props.user.id)) return;
let favorized = favorizedFriends.indexOf(e.instance.props.user.id) > -1; let favorized = favorizedFriends.indexOf(e.instance.props.user.id) > -1;
let hidden = hiddenFriends.indexOf(e.instance.props.user.id) > -1; let hidden = hiddenFriends.indexOf(e.instance.props.user.id) > -1;
e.returnvalue.push(this.settings.general.addFavorizedCategory && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "remove-friend"});
label: favorized ? this.labels.context_unfavorizefriend : this.labels.context_favorizefriend, if (index > -1) children.splice(index + 1, 0, this.settings.general.addFavorizedCategory && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
id: BDFDB.ContextMenuUtils.createItemId(this.name, favorized ? "unfavorize-friend" : "favorize-friend"), label: favorized ? this.labels.context_unfavorizefriend : this.labels.context_favorizefriend,
action: _ => { id: BDFDB.ContextMenuUtils.createItemId(this.name, favorized ? "unfavorize-friend" : "favorize-friend"),
if (favorized) BDFDB.ArrayUtils.remove(favorizedFriends, e.instance.props.user.id, true); action: _ => {
else { if (favorized) BDFDB.ArrayUtils.remove(favorizedFriends, e.instance.props.user.id, true);
favorizedFriends.push(e.instance.props.user.id); else {
BDFDB.ArrayUtils.remove(hiddenFriends, e.instance.props.user.id, true); favorizedFriends.push(e.instance.props.user.id);
} BDFDB.ArrayUtils.remove(hiddenFriends, e.instance.props.user.id, true);
BDFDB.DataUtils.save(favorizedFriends, this, "favorizedFriends");
BDFDB.DataUtils.save(hiddenFriends, this, "hiddenFriends");
this.rerenderList();
} }
}), this.settings.general.addHiddenCategory && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { BDFDB.DataUtils.save(favorizedFriends, this, "favorizedFriends");
label: hidden ? this.labels.context_unhidefriend : this.labels.context_hidefriend, BDFDB.DataUtils.save(hiddenFriends, this, "hiddenFriends");
id: BDFDB.ContextMenuUtils.createItemId(this.name, hidden ? "unhide-friend" : "hide-friend"), this.rerenderList();
action: _ => { }
if (hidden) BDFDB.ArrayUtils.remove(hiddenFriends, e.instance.props.user.id, true); }), this.settings.general.addHiddenCategory && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
else { label: hidden ? this.labels.context_unhidefriend : this.labels.context_hidefriend,
BDFDB.ArrayUtils.remove(favorizedFriends, e.instance.props.user.id, true); id: BDFDB.ContextMenuUtils.createItemId(this.name, hidden ? "unhide-friend" : "hide-friend"),
hiddenFriends.push(e.instance.props.user.id); action: _ => {
} if (hidden) BDFDB.ArrayUtils.remove(hiddenFriends, e.instance.props.user.id, true);
BDFDB.DataUtils.save(favorizedFriends, this, "favorizedFriends"); else {
BDFDB.DataUtils.save(hiddenFriends, this, "hiddenFriends"); BDFDB.ArrayUtils.remove(favorizedFriends, e.instance.props.user.id, true);
this.rerenderList(); hiddenFriends.push(e.instance.props.user.id);
} }
})); BDFDB.DataUtils.save(favorizedFriends, this, "favorizedFriends");
} BDFDB.DataUtils.save(hiddenFriends, this, "hiddenFriends");
this.rerenderList();
}
}));
} }
processTabBar (e) { processTabBar (e) {
@ -315,69 +321,68 @@ module.exports = (_ => {
} }
processPeopleList (e) { processPeopleList (e) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "SectionTitle"}); let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {filter: n => n && n.props && n.props.title && n.props.id});
if (index > -1) { if (index == -1) return;
let users = (BDFDB.ReactUtils.findChild(e.returnvalue, {props: ["statusSections"]}) || {props: {statusSections: []}}).props.statusSections.flat(10); let users = (BDFDB.ReactUtils.findChild(e.returnvalue, {props: ["statusSections"]}) || {props: {statusSections: []}}).props.statusSections.flat(10);
let filteredUsers = users; let filteredUsers = users;
if (this.settings.general.addFavorizedCategory) { if (this.settings.general.addFavorizedCategory) {
if (isFavoritesSelected) filteredUsers = filteredUsers.filter(n => n && n.user && favorizedFriends.indexOf(n.user.id) > -1); if (isFavoritesSelected) filteredUsers = filteredUsers.filter(n => n && n.user && favorizedFriends.indexOf(n.user.id) > -1);
} }
if (this.settings.general.addHiddenCategory) { if (this.settings.general.addHiddenCategory) {
if (isHiddenSelected) filteredUsers = filteredUsers.filter(n => n && n.user && hiddenFriends.indexOf(n.user.id) > -1); if (isHiddenSelected) filteredUsers = filteredUsers.filter(n => n && n.user && hiddenFriends.indexOf(n.user.id) > -1);
else filteredUsers = filteredUsers.filter(n => n && n.user && hiddenFriends.indexOf(n.user.id) == -1); else filteredUsers = filteredUsers.filter(n => n && n.user && hiddenFriends.indexOf(n.user.id) == -1);
} }
children[index].props.title = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, { children[index].props.title = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Flex, {
align: BDFDB.LibraryComponents.Flex.Align.CENTER, align: BDFDB.LibraryComponents.Flex.Align.CENTER,
children: [ children: [
BDFDB.ReactUtils.createElement("div", { BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN._betterfriendlisttitle, className: BDFDB.disCN._betterfriendlisttitle,
children: this.settings.general.addFavorizedCategory && isFavoritesSelected ? `${this.labels.favorites} - ${filteredUsers.filter(u => u && u.key != placeHolderId).length}` : this.settings.general.addHiddenCategory && isHiddenSelected ? `${this.labels.hidden} - ${filteredUsers.filter(u => u && u.key != placeHolderId).length}` : children[index].props.title.replace(users.length, filteredUsers.filter(u => u && u.key != placeHolderId).length) children: this.settings.general.addFavorizedCategory && isFavoritesSelected ? `${this.labels.favorites} - ${filteredUsers.filter(u => u && u.key != placeHolderId).length}` : this.settings.general.addHiddenCategory && isHiddenSelected ? `${this.labels.hidden} - ${filteredUsers.filter(u => u && u.key != placeHolderId).length}` : children[index].props.title.replace(users.length, filteredUsers.filter(u => u && u.key != placeHolderId).length)
}),
this.settings.general.addSortOptions && [
{key: "usernameLower", label: BDFDB.LanguageUtils.LanguageStrings.USER_SETTINGS_LABEL_USERNAME},
{key: "statusIndex", label: BDFDB.LanguageUtils.LibraryStrings.status}
].filter(n => n).map(data => BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.tableheadercellwrapper, BDFDB.disCN.tableheadercell, BDFDB.disCN._betterfriendlistnamecell, sortKey == data.key && BDFDB.disCN.tableheadercellsorted, BDFDB.disCN.tableheadercellclickable),
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.tableheadercellcontent,
children: [
data.label,
sortKey == data.key && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.tableheadersorticon,
name: BDFDB.LibraryComponents.SvgIcon.Names[sortReversed ? "ARROW_UP" : "ARROW_DOWN"]
})
].filter(n => n)
}), }),
this.settings.general.addSortOptions && [ onClick: event => {
{key: "usernameLower", label: BDFDB.LanguageUtils.LanguageStrings.USER_SETTINGS_LABEL_USERNAME}, if (sortKey == data.key) {
{key: "statusIndex", label: BDFDB.LanguageUtils.LibraryStrings.status} if (!sortReversed) sortReversed = true;
].filter(n => n).map(data => BDFDB.ReactUtils.createElement("div", {
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN.tableheadercellwrapper, BDFDB.disCN.tableheadercell, BDFDB.disCN._betterfriendlistnamecell, sortKey == data.key && BDFDB.disCN.tableheadercellsorted, BDFDB.disCN.tableheadercellclickable),
children: BDFDB.ReactUtils.createElement("div", {
className: BDFDB.disCN.tableheadercellcontent,
children: [
data.label,
sortKey == data.key && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
className: BDFDB.disCN.tableheadersorticon,
name: BDFDB.LibraryComponents.SvgIcon.Names[sortReversed ? "ARROW_UP" : "ARROW_DOWN"]
})
].filter(n => n)
}),
onClick: event => {
if (sortKey == data.key) {
if (!sortReversed) sortReversed = true;
else {
sortKey = null;
sortReversed = false;
}
}
else { else {
sortKey = data.key; sortKey = null;
sortReversed = false; sortReversed = false;
} }
this.rerenderList();
} }
})) else {
].flat(10).filter(n => n) sortKey = data.key;
}); sortReversed = false;
} }
this.rerenderList();
}
}))
].flat(10).filter(n => n)
});
} }
processFriendRow (e) { processPeopleListItemFriend (e) {
e.returnvalue.props.mutualGuilds = e.instance.props.mutualGuilds; e.returnvalue.props.mutualGuilds = e.instance.props.mutualGuilds;
} }
processPendingRow (e) { processPeopleListItemPending (e) {
this.processFriendRow(e); this.processPeopleListItemFriend(e);
} }
processBlockedRow (e) { processPeopleListItemBlocked (e) {
this.processFriendRow(e); this.processPeopleListItemFriend(e);
} }
processPeopleListItem (e) { processPeopleListItem (e) {
@ -402,7 +407,7 @@ module.exports = (_ => {
} }
injectMutualGuilds (returnvalue, mutualGuilds) { injectMutualGuilds (returnvalue, mutualGuilds) {
let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {name: "UserInfo"}); let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {filter: n => n && n.props && n.props.subText && n.props.user});
if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildSummaryItem, { if (index > -1) children.splice(index + 1, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.GuildSummaryItem, {
className: BDFDB.disCN._betterfriendlistmutualguilds, className: BDFDB.disCN._betterfriendlistmutualguilds,
guilds: mutualGuilds, guilds: mutualGuilds,