Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit d6ca059

Browse files
authored
Merge pull request #4960 from matrix-org/travis/room-list/default-order
Fix default sorting mechanics for new room list
2 parents cc49e64 + 40ab3e2 commit d6ca059

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/stores/room-list/RoomListStore2.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import { TagWatcher } from "./TagWatcher";
3030
import RoomViewStore from "../RoomViewStore";
3131
import { Algorithm, LIST_UPDATED_EVENT } from "./algorithms/Algorithm";
3232
import { EffectiveMembership, getEffectiveMembership } from "./membership";
33-
import { ListLayout } from "./ListLayout";
3433
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
3534
import RoomListLayoutStore from "./RoomListLayoutStore";
3635
import { MarkedExecution } from "../../utils/MarkedExecution";
@@ -425,7 +424,8 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
425424

426425
// logic must match calculateListOrder
427426
private calculateTagSorting(tagId: TagID): SortAlgorithm {
428-
const defaultSort = SortAlgorithm.Alphabetic;
427+
const isDefaultRecent = tagId === DefaultTagID.Invite || tagId === DefaultTagID.DM;
428+
const defaultSort = isDefaultRecent ? SortAlgorithm.Recent : SortAlgorithm.Alphabetic;
429429
const settingAlphabetical = SettingsStore.getValue("RoomList.orderAlphabetically", null, true);
430430
const definedSort = this.getTagSorting(tagId);
431431
const storedSort = this.getStoredTagSorting(tagId);

src/stores/room-list/algorithms/tag-sorting/RecentAlgorithm.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ export class RecentAlgorithm implements IAlgorithm {
3838
// actually changed (probably needs to be done higher up?) then we could do an
3939
// insertion sort or similar on the limited set of changes.
4040

41-
const myUserId = MatrixClientPeg.get().getUserId();
41+
// TODO: Don't assume we're using the same client as the peg
42+
let myUserId = '';
43+
if (MatrixClientPeg.get()) {
44+
myUserId = MatrixClientPeg.get().getUserId();
45+
}
4246

4347
const tsCache: { [roomId: string]: number } = {};
4448
const getLastTs = (r: Room) => {
@@ -68,7 +72,6 @@ export class RecentAlgorithm implements IAlgorithm {
6872
const ev = r.timeline[i];
6973
if (!ev.getTs()) continue; // skip events that don't have timestamps (tests only?)
7074

71-
// TODO: Don't assume we're using the same client as the peg
7275
if (ev.getSender() === myUserId || Unread.eventTriggersUnreadCount(ev)) {
7376
return ev.getTs();
7477
}

0 commit comments

Comments
 (0)