mirror of
https://github.com/element-hq/element-web.git
synced 2024-12-16 20:01:54 +03:00
Remove unreadRoomId from summarized notification state
This commit is contained in:
parent
746b11b24d
commit
1b21c8f732
4 changed files with 28 additions and 16 deletions
|
@ -68,7 +68,7 @@ interface IState {
|
||||||
suggestedRooms: ISuggestedRoom[];
|
suggestedRooms: ISuggestedRoom[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const TAG_ORDER: TagID[] = [
|
export const TAG_ORDER: TagID[] = [
|
||||||
DefaultTagID.Invite,
|
DefaultTagID.Invite,
|
||||||
DefaultTagID.Favourite,
|
DefaultTagID.Favourite,
|
||||||
DefaultTagID.DM,
|
DefaultTagID.DM,
|
||||||
|
|
|
@ -38,6 +38,7 @@ import { arrayHasDiff } from "../utils/arrays";
|
||||||
import { objectDiff } from "../utils/objects";
|
import { objectDiff } from "../utils/objects";
|
||||||
import { arrayHasOrderChange } from "../utils/arrays";
|
import { arrayHasOrderChange } from "../utils/arrays";
|
||||||
import { reorderLexicographically } from "../utils/stringOrderField";
|
import { reorderLexicographically } from "../utils/stringOrderField";
|
||||||
|
import { TAG_ORDER } from "../components/views/rooms/RoomList";
|
||||||
|
|
||||||
type SpaceKey = string | symbol;
|
type SpaceKey = string | symbol;
|
||||||
|
|
||||||
|
@ -128,16 +129,33 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
|
||||||
if (space && !space.isSpaceRoom()) return;
|
if (space && !space.isSpaceRoom()) return;
|
||||||
if (space !== this.activeSpace) await this.setActiveSpace(space);
|
if (space !== this.activeSpace) await this.setActiveSpace(space);
|
||||||
|
|
||||||
const notificationState = space
|
if (space) {
|
||||||
? this.getNotificationState(space.roomId)
|
const notificationState = this.getNotificationState(space.roomId)
|
||||||
: RoomNotificationStateStore.instance.globalState;
|
|
||||||
|
|
||||||
if (notificationState.count) {
|
|
||||||
const roomId = notificationState.getFirstRoomWithNotifications();
|
const roomId = notificationState.getFirstRoomWithNotifications();
|
||||||
defaultDispatcher.dispatch({
|
defaultDispatcher.dispatch({
|
||||||
action: "view_room",
|
action: "view_room",
|
||||||
room_id: roomId,
|
room_id: roomId,
|
||||||
context_switch: true,
|
context_switch: true,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const lists = RoomListStore.instance.unfilteredLists;
|
||||||
|
TAG_ORDER.every(t => {
|
||||||
|
const listRooms = lists[t];
|
||||||
|
const unreadRoom = listRooms.find((r: Room)=> {
|
||||||
|
if (this.showInHomeSpace(r)) {
|
||||||
|
const state = RoomNotificationStateStore.instance.getRoomState(r);
|
||||||
|
return state.isUnread;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (unreadRoom) {
|
||||||
|
defaultDispatcher.dispatch({
|
||||||
|
action: "view_room",
|
||||||
|
room_id: unreadRoom.roomId,
|
||||||
|
context_switch: true,
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ export class SpaceNotificationState extends NotificationState {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFirstRoomWithNotifications() {
|
public getFirstRoomWithNotifications() {
|
||||||
return this.rooms.find((room) => room._notificationCounts.total > 0).roomId;
|
return this.rooms.find((room) => room.getUnreadNotificationCount() > 0).roomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
|
|
|
@ -32,7 +32,6 @@ export class SummarizedNotificationState extends NotificationState {
|
||||||
super();
|
super();
|
||||||
this._symbol = null;
|
this._symbol = null;
|
||||||
this._count = 0;
|
this._count = 0;
|
||||||
this.unreadRoomId = null;
|
|
||||||
this._color = NotificationColor.None;
|
this._color = NotificationColor.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,10 +39,6 @@ export class SummarizedNotificationState extends NotificationState {
|
||||||
return this.totalStatesWithUnread;
|
return this.totalStatesWithUnread;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getFirstRoomWithNotifications() {
|
|
||||||
return this.unreadRoomId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append a notification state to this snapshot, taking the loudest NotificationColor
|
* Append a notification state to this snapshot, taking the loudest NotificationColor
|
||||||
* of the two. By default this will not adopt the symbol of the other notification
|
* of the two. By default this will not adopt the symbol of the other notification
|
||||||
|
@ -63,7 +58,6 @@ export class SummarizedNotificationState extends NotificationState {
|
||||||
this._color = other.color;
|
this._color = other.color;
|
||||||
}
|
}
|
||||||
if (other.hasUnreadCount) {
|
if (other.hasUnreadCount) {
|
||||||
this.unreadRoomId = !this.unreadRoomId ? other.room.roomId : this.unreadRoomId;
|
|
||||||
this.totalStatesWithUnread++;
|
this.totalStatesWithUnread++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue