Include non-matching DMs in Spotlight recent conversations when the DM's userId is part of the search API results (#11374)

* This addresses two issues:

     1. Include non-matching DMs in Spotlight suggestions if the userId of the DM is included in the user directory search results
     2. The user directory search results order is kept when there is no relevant activity between users, instead of sorting by MXID

* Applying feedback from PR:
1. Updated comments
2. Renamed users to userDirectorySearchResults
3. Makes sure linter is happy
This commit is contained in:
Milton Moura 2023-08-10 17:27:24 +00:00 committed by GitHub
parent c55400de18
commit d240f06810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 12 deletions

View file

@ -16,7 +16,6 @@ limitations under the License.
import { groupBy, mapValues, maxBy, minBy, sumBy, takeRight } from "lodash";
import { MatrixClient, Room, RoomMember } from "matrix-js-sdk/src/matrix";
import { compare } from "matrix-js-sdk/src/utils";
import { Member } from "./direct-messages";
import DMRoomMap from "./DMRoomMap";
@ -39,7 +38,9 @@ export const compareMembers =
if (aScore === bScore) {
if (aNumRooms === bNumRooms) {
return compare(a.userId, b.userId);
// If there is no activity between members,
// keep the order received from the user directory search results
return 0;
}
return bNumRooms - aNumRooms;