mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Merge pull request #4960 from matrix-org/travis/room-list/default-order
Fix default sorting mechanics for new room list
This commit is contained in:
commit
d6ca05938d
@ -30,7 +30,6 @@ import { TagWatcher } from "./TagWatcher";
|
|||||||
import RoomViewStore from "../RoomViewStore";
|
import RoomViewStore from "../RoomViewStore";
|
||||||
import { Algorithm, LIST_UPDATED_EVENT } from "./algorithms/Algorithm";
|
import { Algorithm, LIST_UPDATED_EVENT } from "./algorithms/Algorithm";
|
||||||
import { EffectiveMembership, getEffectiveMembership } from "./membership";
|
import { EffectiveMembership, getEffectiveMembership } from "./membership";
|
||||||
import { ListLayout } from "./ListLayout";
|
|
||||||
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
|
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
|
||||||
import RoomListLayoutStore from "./RoomListLayoutStore";
|
import RoomListLayoutStore from "./RoomListLayoutStore";
|
||||||
import { MarkedExecution } from "../../utils/MarkedExecution";
|
import { MarkedExecution } from "../../utils/MarkedExecution";
|
||||||
@ -425,7 +424,8 @@ export class RoomListStore2 extends AsyncStore<ActionPayload> {
|
|||||||
|
|
||||||
// logic must match calculateListOrder
|
// logic must match calculateListOrder
|
||||||
private calculateTagSorting(tagId: TagID): SortAlgorithm {
|
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 settingAlphabetical = SettingsStore.getValue("RoomList.orderAlphabetically", null, true);
|
||||||
const definedSort = this.getTagSorting(tagId);
|
const definedSort = this.getTagSorting(tagId);
|
||||||
const storedSort = this.getStoredTagSorting(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
|
// actually changed (probably needs to be done higher up?) then we could do an
|
||||||
// insertion sort or similar on the limited set of changes.
|
// 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 tsCache: { [roomId: string]: number } = {};
|
||||||
const getLastTs = (r: Room) => {
|
const getLastTs = (r: Room) => {
|
||||||
@ -68,7 +72,6 @@ export class RecentAlgorithm implements IAlgorithm {
|
|||||||
const ev = r.timeline[i];
|
const ev = r.timeline[i];
|
||||||
if (!ev.getTs()) continue; // skip events that don't have timestamps (tests only?)
|
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)) {
|
if (ev.getSender() === myUserId || Unread.eventTriggersUnreadCount(ev)) {
|
||||||
return ev.getTs();
|
return ev.getTs();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user