From 03d7e0fb93a32c2ee6984cfdb7e2d5ea3f4de127 Mon Sep 17 00:00:00 2001 From: dolfies Date: Fri, 3 May 2024 09:09:54 -0400 Subject: [PATCH] fix sort conflict of ImplicitRelationships & SortFriendRequests (#2408) --- src/plugins/implicitRelationships/index.ts | 8 ++++---- src/plugins/sortFriendRequests/index.tsx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index be17e0fe4..15165d64a 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -81,8 +81,8 @@ export default definePlugin({ find: "getRelationshipCounts(){", replacement: { predicate: () => Settings.plugins.ImplicitRelationships.sortByAffinity, - match: /\.sortBy\(\i=>\i\.comparator\)/, - replace: "$&.sortBy((row) => $self.sortList(row))" + match: /\}\)\.sortBy\((.+?)\)\.value\(\)/, + 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 ? -UserAffinitiesStore.getUserAffinity(row.user.id)?.affinity ?? 0 - : row.comparator; + : comparator(row); }, async fetchImplicitRelationships() { diff --git a/src/plugins/sortFriendRequests/index.tsx b/src/plugins/sortFriendRequests/index.tsx index 32579a803..7033591bd 100644 --- a/src/plugins/sortFriendRequests/index.tsx +++ b/src/plugins/sortFriendRequests/index.tsx @@ -41,8 +41,8 @@ export default definePlugin({ patches: [{ find: "getRelationshipCounts(){", replacement: { - match: /\.sortBy\(\i=>\i\.comparator\)/, - replace: "$&.sortBy((row) => $self.sortList(row))" + match: /\}\)\.sortBy\((.+?)\)\.value\(\)/, + replace: "}).sortBy(row => $self.wrapSort(($1), row)).value()" } }, { 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 ? -this.getSince(row.user) - : row.comparator; + : comparator(row); }, getSince(user: User) {