fix sort conflict of ImplicitRelationships & SortFriendRequests (#2408)
This commit is contained in:
parent
84c53b4a27
commit
03d7e0fb93
2 changed files with 8 additions and 8 deletions
|
@ -81,8 +81,8 @@ export default definePlugin({
|
||||||
find: "getRelationshipCounts(){",
|
find: "getRelationshipCounts(){",
|
||||||
replacement: {
|
replacement: {
|
||||||
predicate: () => Settings.plugins.ImplicitRelationships.sortByAffinity,
|
predicate: () => Settings.plugins.ImplicitRelationships.sortByAffinity,
|
||||||
match: /\.sortBy\(\i=>\i\.comparator\)/,
|
match: /\}\)\.sortBy\((.+?)\)\.value\(\)/,
|
||||||
replace: "$&.sortBy((row) => $self.sortList(row))"
|
replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -120,10 +120,10 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
sortList(row: any) {
|
wrapSort(comparator: Function, row: any) {
|
||||||
return row.type === 5
|
return row.type === 5
|
||||||
? -UserAffinitiesStore.getUserAffinity(row.user.id)?.affinity ?? 0
|
? -UserAffinitiesStore.getUserAffinity(row.user.id)?.affinity ?? 0
|
||||||
: row.comparator;
|
: comparator(row);
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchImplicitRelationships() {
|
async fetchImplicitRelationships() {
|
||||||
|
|
|
@ -41,8 +41,8 @@ export default definePlugin({
|
||||||
patches: [{
|
patches: [{
|
||||||
find: "getRelationshipCounts(){",
|
find: "getRelationshipCounts(){",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.sortBy\(\i=>\i\.comparator\)/,
|
match: /\}\)\.sortBy\((.+?)\)\.value\(\)/,
|
||||||
replace: "$&.sortBy((row) => $self.sortList(row))"
|
replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()"
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
find: ".Messages.FRIEND_REQUEST_CANCEL",
|
find: ".Messages.FRIEND_REQUEST_CANCEL",
|
||||||
|
@ -53,10 +53,10 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
sortList(row: any) {
|
wrapSort(comparator: Function, row: any) {
|
||||||
return row.type === 3 || row.type === 4
|
return row.type === 3 || row.type === 4
|
||||||
? -this.getSince(row.user)
|
? -this.getSince(row.user)
|
||||||
: row.comparator;
|
: comparator(row);
|
||||||
},
|
},
|
||||||
|
|
||||||
getSince(user: User) {
|
getSince(user: User) {
|
||||||
|
|
Loading…
Reference in a new issue