Unread Sorting - Add option for sorting in OptionsMenuView (#31754)

* Add new sort option

* Support new sorting algorithm in vm

* Add option item for unread sorter

* Add tests
This commit is contained in:
R Midhun Suresh
2026-01-22 15:26:47 +05:30
committed by GitHub
parent b9cdc0390a
commit d6d647f56d
6 changed files with 65 additions and 5 deletions

View File

@@ -170,7 +170,18 @@ export class RoomListHeaderViewModel
};
public sort = (option: SortOption): void => {
const sortingAlgorithm = option === "recent" ? SortingAlgorithm.Recency : SortingAlgorithm.Alphabetic;
let sortingAlgorithm: SortingAlgorithm;
switch (option) {
case "alphabetical":
sortingAlgorithm = SortingAlgorithm.Alphabetic;
break;
case "recent":
sortingAlgorithm = SortingAlgorithm.Recency;
break;
case "unread-first":
sortingAlgorithm = SortingAlgorithm.Unread;
break;
}
RoomListStoreV3.instance.resort(sortingAlgorithm);
this.snapshot.merge({ activeSortOption: option });
};
@@ -192,8 +203,20 @@ export class RoomListHeaderViewModel
*/
function getInitialSnapshot(spaceStore: SpaceStoreClass, matrixClient: MatrixClient): RoomListHeaderViewSnapshot {
const sortingAlgorithm = SettingsStore.getValue("RoomList.preferredSorting");
const activeSortOption =
sortingAlgorithm === SortingAlgorithm.Recency ? ("recent" as const) : ("alphabetical" as const);
let activeSortOption: SortOption;
switch (sortingAlgorithm) {
case SortingAlgorithm.Alphabetic:
activeSortOption = "alphabetical";
break;
case SortingAlgorithm.Recency:
activeSortOption = "recent";
break;
case SortingAlgorithm.Unread:
activeSortOption = "unread-first";
break;
}
const isMessagePreviewEnabled = SettingsStore.getValue("RoomList.showMessagePreview");
return {