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",
|
description: "Sorts friend requests by date of receipt",
|
||||||
|
|
||||||
patches: [{
|
patches: [{
|
||||||
find: ".PENDING_INCOMING||",
|
find: "getRelationshipCounts(){",
|
||||||
replacement: [{
|
replacement: {
|
||||||
match: /\.sortBy\(\(function\((\w)\){return \w{1,3}\.comparator}\)\)/,
|
match: /\.sortBy\(\i=>\i\.comparator\)/,
|
||||||
// If the row type is 3 or 4 (pendinng incoming or outgoing), sort by date of receipt
|
replace: ".sortBy((row) => $self.sortList(row))"
|
||||||
// Otherwise, use the default comparator
|
}
|
||||||
replace: (_, row) => `.sortBy((function(${row}) {
|
}, {
|
||||||
return ${row}.type === 3 || ${row}.type === 4
|
find: "RelationshipTypes.PENDING_INCOMING?",
|
||||||
? -Vencord.Plugins.plugins.SortFriendRequests.getSince(${row}.user)
|
replacement: {
|
||||||
: ${row}.comparator
|
|
||||||
}))`
|
|
||||||
}, {
|
|
||||||
predicate: () => Settings.plugins.SortFriendRequests.showDates,
|
predicate: () => Settings.plugins.SortFriendRequests.showDates,
|
||||||
match: /(user:(\w{1,3}),.{10,30}),subText:(\w{1,3}),(.{10,30}userInfo}\))/,
|
match: /(user:(\i),.{10,50}),subText:(\i),(className:\i\.userInfo}\))/,
|
||||||
// Show dates in the friend request list
|
replace: (_, pre, user, subtext, post) => `${pre},
|
||||||
replace: (_, pre, user, subText, post) => `${pre},
|
subText: $self.makeSubtext(${subtext}, ${user}),
|
||||||
subText: Vencord.Plugins.plugins.SortFriendRequests.makeSubtext(${subText}, ${user}),
|
${post}`
|
||||||
${post}`
|
}
|
||||||
}]
|
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
sortList(row: any) {
|
||||||
|
return row.type === 3 || row.type === 4
|
||||||
|
? -this.getSince(row.user)
|
||||||
|
: row.comparator;
|
||||||
|
},
|
||||||
|
|
||||||
getSince(user: User) {
|
getSince(user: User) {
|
||||||
return new Date(RelationshipStore.getSince(user.id));
|
return new Date(RelationshipStore.getSince(user.id));
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user