diff --git a/src/plugins/sortFriendRequests/index.tsx b/src/plugins/sortFriendRequests/index.tsx index b9732afb..3698379c 100644 --- a/src/plugins/sortFriendRequests/index.tsx +++ b/src/plugins/sortFriendRequests/index.tsx @@ -29,26 +29,28 @@ export default definePlugin({ description: "Sorts friend requests by date of receipt", patches: [{ - find: ".PENDING_INCOMING||", - replacement: [{ - match: /\.sortBy\(\(function\((\w)\){return \w{1,3}\.comparator}\)\)/, - // If the row type is 3 or 4 (pendinng incoming or outgoing), sort by date of receipt - // Otherwise, use the default comparator - replace: (_, row) => `.sortBy((function(${row}) { - return ${row}.type === 3 || ${row}.type === 4 - ? -Vencord.Plugins.plugins.SortFriendRequests.getSince(${row}.user) - : ${row}.comparator - }))` - }, { + find: "getRelationshipCounts(){", + replacement: { + match: /\.sortBy\(\i=>\i\.comparator\)/, + replace: ".sortBy((row) => $self.sortList(row))" + } + }, { + find: "RelationshipTypes.PENDING_INCOMING?", + replacement: { predicate: () => Settings.plugins.SortFriendRequests.showDates, - match: /(user:(\w{1,3}),.{10,30}),subText:(\w{1,3}),(.{10,30}userInfo}\))/, - // Show dates in the friend request list - replace: (_, pre, user, subText, post) => `${pre}, - subText: Vencord.Plugins.plugins.SortFriendRequests.makeSubtext(${subText}, ${user}), - ${post}` - }] + match: /(user:(\i),.{10,50}),subText:(\i),(className:\i\.userInfo}\))/, + replace: (_, pre, user, subtext, post) => `${pre}, + subText: $self.makeSubtext(${subtext}, ${user}), + ${post}` + } }], + sortList(row: any) { + return row.type === 3 || row.type === 4 + ? -this.getSince(row.user) + : row.comparator; + }, + getSince(user: User) { return new Date(RelationshipStore.getSince(user.id)); },