fix: sortFriendRequests patches (#1848)
This commit is contained in:
parent
cd06980016
commit
7de1b5dcb6
@ -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));
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user