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

Sort muted rooms to the bottom of their section of the room list #10592

Merged
merged 39 commits into from
May 5, 2023
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
b937438
muted-to-the-bottom POC
Apr 13, 2023
5292e47
split muted rooms in natural algorithm
Apr 18, 2023
07606b1
add previous event to account data dispatch
Apr 18, 2023
668cf8e
add muted to notification state
Apr 18, 2023
6450a73
sort muted rooms to the bottom
Apr 18, 2023
94ed2a6
only split muted rooms when sorting is RECENT
Apr 19, 2023
4352b46
Merge branch 'develop' into kerry/sort-muted
Apr 19, 2023
1b095d3
remove debugs
Apr 19, 2023
3ed9133
Merge branch 'develop' into kerry/sort-muted
Apr 19, 2023
acb7606
use RoomNotifState better
Apr 19, 2023
17c72fb
add default notifications test util
Apr 17, 2023
e638e15
test getChangedOverrideRoomPushRules
Apr 20, 2023
cd00719
remove file
Apr 20, 2023
625e286
test roomudpate in roomliststore
Apr 20, 2023
b8cb050
unit test ImportanceAlgorithm
Apr 21, 2023
86194ab
Merge branch 'develop' into kerry/test-importance-algorithm
Apr 21, 2023
e44f8be
strict fixes
Apr 21, 2023
b92f410
Merge branch 'develop' into kerry/sort-muted
Apr 21, 2023
a4a05d2
Merge branch 'kerry/test-importance-algorithm' into kerry/sort-muted
Apr 21, 2023
4028131
test recent x importance with muted rooms
Apr 21, 2023
f5faa5f
unit test NaturalAlgorithm
Apr 21, 2023
097b81b
Merge branch 'kerry/test-importance-algorithm' into kerry/sort-muted
Apr 21, 2023
1c81d6f
Merge branch 'develop' into kerry/sort-muted
Apr 24, 2023
652a41f
test naturalalgorithm with muted rooms
Apr 24, 2023
84ea40f
strict fixes
Apr 24, 2023
b2e9281
Merge branch 'develop' into kerry/sort-muted
Apr 25, 2023
bbb19f5
comments
Apr 25, 2023
6a15a48
add push rules test utility
Apr 25, 2023
33a32f6
Merge branch 'kerry/push-rules-test-util' into kerry/sort-muted
Apr 25, 2023
bfb9ed6
strict fixes
Apr 26, 2023
6eb155b
more strict
Apr 26, 2023
c418923
Merge branch 'develop' into kerry/sort-muted
Apr 27, 2023
0b9997c
tidy comment
Apr 27, 2023
237b4ca
document previousevent on account data dispatch event
Apr 27, 2023
43f3316
simplify (?) room mute rule utilities, comments
Apr 27, 2023
ca05e61
Merge branch 'develop' into kerry/sort-muted
Apr 28, 2023
8654bea
Merge branch 'develop' into kerry/sort-muted
May 1, 2023
30be86f
remove debug
May 5, 2023
947f994
Merge branch 'develop' into kerry/sort-muted
May 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove debugs
Kerry Archibald committed Apr 19, 2023

Verified

This commit was signed with the committer’s verified signature.
lucasssvaz Lucas Saavedra Vaz
commit 1b095d3a548a7a91effea6889f9b3fb335763088
2 changes: 1 addition & 1 deletion src/stores/notifications/NotificationState.ts
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ export abstract class NotificationState
protected _symbol: string | null = null;
protected _count = 0;
protected _color: NotificationColor = NotificationColor.None;
protected _muted: boolean = false;
protected _muted = false;

private watcherReferences: string[] = [];

2 changes: 0 additions & 2 deletions src/stores/room-list/RoomListStore.ts
Original file line number Diff line number Diff line change
@@ -553,8 +553,6 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> implements
*/
public regenerateAllLists({ trigger = true }): void {
logger.warn("Regenerating all room lists");

debugger;

const rooms = this.getPlausibleRooms();

Original file line number Diff line number Diff line change
@@ -96,11 +96,10 @@ export class ImportanceAlgorithm extends OrderingAlgorithm {
// It's fine for us to call this a lot because it's cached, and we shouldn't be
// wasting anything by doing so as the store holds single references
const state = RoomNotificationStateStore.instance.getRoomState(room);
return (this.isMutedToBottom && state.muted) ? NotificationColor.Muted : state.color;
return this.isMutedToBottom && state.muted ? NotificationColor.Muted : state.color;
}

public setRooms(rooms: Room[]): void {
console.log('hhh', 'ImportanceAlgorithm:setRooms', this.isMutedToBottom);
if (this.sortingAlgorithm === SortAlgorithm.Manual) {
this.cachedOrderedRooms = sortRoomsWithAlgorithm(rooms, this.tagId, this.sortingAlgorithm);
} else {
@@ -163,7 +162,6 @@ export class ImportanceAlgorithm extends OrderingAlgorithm {
}

public handleRoomUpdate(room: Room, cause: RoomUpdateCause): boolean {
console.log('hhh', 'ImportanceAlgorithm:handleRoomUpdate', this.isMutedToBottom);
if (cause === RoomUpdateCause.NewRoom || cause === RoomUpdateCause.RoomRemoved) {
return this.handleSplice(room, cause);
}
Original file line number Diff line number Diff line change
@@ -42,7 +42,6 @@ export class NaturalAlgorithm extends OrderingAlgorithm {
}

public setRooms(rooms: Room[]): void {
console.log('hhh', 'NaturalAlgorithm:setRooms', this.isMutedToBottom);
const { defaultRooms, mutedRooms } = this.categorizeRooms(rooms);

this.cachedCategorizedOrderedRooms = {
@@ -53,7 +52,6 @@ export class NaturalAlgorithm extends OrderingAlgorithm {
}

public handleRoomUpdate(room: Room, cause: RoomUpdateCause): boolean {
console.log('hhh', 'NaturalAlgorithm:handleRoomUpdate', this.isMutedToBottom);
const isSplice = cause === RoomUpdateCause.NewRoom || cause === RoomUpdateCause.RoomRemoved;
const isInPlace =
cause === RoomUpdateCause.Timeline ||
@@ -150,7 +148,7 @@ export class NaturalAlgorithm extends OrderingAlgorithm {

private categorizeRooms(rooms: Room[]): NaturalCategorizedRoomMap {
if (!this.isMutedToBottom) {
return { defaultRooms: rooms, mutedRooms: []};
return { defaultRooms: rooms, mutedRooms: [] };
}
return rooms.reduce<NaturalCategorizedRoomMap>(
(acc, room: Room) => {
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ export abstract class OrderingAlgorithm {
return this.cachedOrderedRooms;
}

private get isMutedToBottom(): boolean {
public get isMutedToBottom(): boolean {
return this.sortingAlgorithm === SortAlgorithm.Recent;
}

9 changes: 4 additions & 5 deletions src/stores/room-list/algorithms/list-ordering/index.ts
Original file line number Diff line number Diff line change
@@ -21,12 +21,12 @@ import { TagID } from "../../models";
import { OrderingAlgorithm } from "./OrderingAlgorithm";

interface AlgorithmFactory {
(tagId: TagID, initialSortingAlgorithm: SortAlgorithm, mutedToTheBottom?: boolean): OrderingAlgorithm;
(tagId: TagID, initialSortingAlgorithm: SortAlgorithm): OrderingAlgorithm;
}

const ALGORITHM_FACTORIES: { [algorithm in ListAlgorithm]: AlgorithmFactory } = {
[ListAlgorithm.Natural]: (tagId, initSort, mutedToTheBottom) => new NaturalAlgorithm(tagId, initSort, mutedToTheBottom),
[ListAlgorithm.Importance]: (tagId, initSort, mutedToTheBottom) => new ImportanceAlgorithm(tagId, initSort, mutedToTheBottom),
[ListAlgorithm.Natural]: (tagId, initSort) => new NaturalAlgorithm(tagId, initSort),
[ListAlgorithm.Importance]: (tagId, initSort) => new ImportanceAlgorithm(tagId, initSort),
};

/**
@@ -40,11 +40,10 @@ export function getListAlgorithmInstance(
algorithm: ListAlgorithm,
tagId: TagID,
initSort: SortAlgorithm,
mutedToTheBottom?: boolean,
): OrderingAlgorithm {
if (!ALGORITHM_FACTORIES[algorithm]) {
throw new Error(`${algorithm} is not a known algorithm`);
}

return ALGORITHM_FACTORIES[algorithm](tagId, initSort, mutedToTheBottom);
return ALGORITHM_FACTORIES[algorithm](tagId, initSort);
}