mirror of https://github.com/vector-im/riot-web
Merge pull request #4960 from matrix-org/travis/room-list/default-order
Fix default sorting mechanics for new room listpull/21833/head
commit
d6ca05938d
|
@ -30,7 +30,6 @@ import { TagWatcher } from "./TagWatcher";
|
|||
import RoomViewStore from "../RoomViewStore";
|
||||
import { Algorithm, LIST_UPDATED_EVENT } from "./algorithms/Algorithm";
|
||||
import { EffectiveMembership, getEffectiveMembership } from "./membership";
|
||||
import { ListLayout } from "./ListLayout";
|
||||
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
|
||||
import RoomListLayoutStore from "./RoomListLayoutStore";
|
||||
import { MarkedExecution } from "../../utils/MarkedExecution";
|
||||
|
@ -425,7 +424,8 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
|
|||
|
||||
// logic must match calculateListOrder
|
||||
private calculateTagSorting(tagId: TagID): SortAlgorithm {
|
||||
const defaultSort = SortAlgorithm.Alphabetic;
|
||||
const isDefaultRecent = tagId === DefaultTagID.Invite || tagId === DefaultTagID.DM;
|
||||
const defaultSort = isDefaultRecent ? SortAlgorithm.Recent : SortAlgorithm.Alphabetic;
|
||||
const settingAlphabetical = SettingsStore.getValue("RoomList.orderAlphabetically", null, true);
|
||||
const definedSort = this.getTagSorting(tagId);
|
||||
const storedSort = this.getStoredTagSorting(tagId);
|
||||
|
|
|
@ -38,7 +38,11 @@ export class RecentAlgorithm implements IAlgorithm {
|
|||
// actually changed (probably needs to be done higher up?) then we could do an
|
||||
// insertion sort or similar on the limited set of changes.
|
||||
|
||||
const myUserId = MatrixClientPeg.get().getUserId();
|
||||
// TODO: Don't assume we're using the same client as the peg
|
||||
let myUserId = '';
|
||||
if (MatrixClientPeg.get()) {
|
||||
myUserId = MatrixClientPeg.get().getUserId();
|
||||
}
|
||||
|
||||
const tsCache: { [roomId: string]: number } = {};
|
||||
const getLastTs = (r: Room) => {
|
||||
|
@ -68,7 +72,6 @@ export class RecentAlgorithm implements IAlgorithm {
|
|||
const ev = r.timeline[i];
|
||||
if (!ev.getTs()) continue; // skip events that don't have timestamps (tests only?)
|
||||
|
||||
// TODO: Don't assume we're using the same client as the peg
|
||||
if (ev.getSender() === myUserId || Unread.eventTriggersUnreadCount(ev)) {
|
||||
return ev.getTs();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue