Show knock rooms in the list (#11573)
* Show knock rooms in the list Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> * Pass userId to IndexedDBStore Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> * Revert "Pass userId to IndexedDBStore" Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> * Code review changes Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> --------- Signed-off-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net> Co-authored-by: Mikhail Aheichyk <mikhail.aheichyk@nordeck.net>
This commit is contained in:
co-authored by
Mikhail Aheichyk
parent
f9f2e79fd9
commit
86e86ba49f
@@ -25,6 +25,7 @@ export interface INotificationStateSnapshotParams {
|
||||
count: number;
|
||||
color: NotificationColor;
|
||||
muted: boolean;
|
||||
knocked: boolean;
|
||||
}
|
||||
|
||||
export enum NotificationStateEvents {
|
||||
@@ -44,6 +45,7 @@ export abstract class NotificationState
|
||||
protected _count = 0;
|
||||
protected _color: NotificationColor = NotificationColor.None;
|
||||
protected _muted = false;
|
||||
protected _knocked = false;
|
||||
|
||||
private watcherReferences: string[] = [];
|
||||
|
||||
@@ -72,6 +74,10 @@ export abstract class NotificationState
|
||||
return this._muted;
|
||||
}
|
||||
|
||||
public get knocked(): boolean {
|
||||
return this._knocked;
|
||||
}
|
||||
|
||||
public get isIdle(): boolean {
|
||||
return this.color <= NotificationColor.None;
|
||||
}
|
||||
@@ -117,17 +123,31 @@ export class NotificationStateSnapshot {
|
||||
private readonly count: number;
|
||||
private readonly color: NotificationColor;
|
||||
private readonly muted: boolean;
|
||||
private readonly knocked: boolean;
|
||||
|
||||
public constructor(state: INotificationStateSnapshotParams) {
|
||||
this.symbol = state.symbol;
|
||||
this.count = state.count;
|
||||
this.color = state.color;
|
||||
this.muted = state.muted;
|
||||
this.knocked = state.knocked;
|
||||
}
|
||||
|
||||
public isDifferentFrom(other: INotificationStateSnapshotParams): boolean {
|
||||
const before = { count: this.count, symbol: this.symbol, color: this.color, muted: this.muted };
|
||||
const after = { count: other.count, symbol: other.symbol, color: other.color, muted: other.muted };
|
||||
const before = {
|
||||
count: this.count,
|
||||
symbol: this.symbol,
|
||||
color: this.color,
|
||||
muted: this.muted,
|
||||
knocked: this.knocked,
|
||||
};
|
||||
const after = {
|
||||
count: other.count,
|
||||
symbol: other.symbol,
|
||||
color: other.color,
|
||||
muted: other.muted,
|
||||
knocked: other.knocked,
|
||||
};
|
||||
return JSON.stringify(before) !== JSON.stringify(after);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import { readReceiptChangeIsFor } from "../../utils/read-receipts";
|
||||
import * as RoomNotifs from "../../RoomNotifs";
|
||||
import { NotificationState } from "./NotificationState";
|
||||
import SettingsStore from "../../settings/SettingsStore";
|
||||
|
||||
export class RoomNotificationState extends NotificationState implements IDestroyable {
|
||||
public constructor(public readonly room: Room) {
|
||||
@@ -92,10 +93,12 @@ export class RoomNotificationState extends NotificationState implements IDestroy
|
||||
const { color, symbol, count } = RoomNotifs.determineUnreadState(this.room);
|
||||
const muted =
|
||||
RoomNotifs.getRoomNotifsState(this.room.client, this.room.roomId) === RoomNotifs.RoomNotifState.Mute;
|
||||
const knocked = SettingsStore.getValue("feature_ask_to_join") && this.room.getMyMembership() === "knock";
|
||||
this._color = color;
|
||||
this._symbol = symbol;
|
||||
this._count = count;
|
||||
this._muted = muted;
|
||||
this._knocked = knocked;
|
||||
|
||||
// finally, publish an update if needed
|
||||
this.emitIfUpdated(snapshot);
|
||||
|
||||
@@ -25,7 +25,7 @@ import defaultDispatcher, { MatrixDispatcher } from "../../dispatcher/dispatcher
|
||||
import { readReceiptChangeIsFor } from "../../utils/read-receipts";
|
||||
import { FILTER_CHANGED, IFilterCondition } from "./filters/IFilterCondition";
|
||||
import { Algorithm, LIST_UPDATED_EVENT } from "./algorithms/Algorithm";
|
||||
import { EffectiveMembership, getEffectiveMembership } from "../../utils/membership";
|
||||
import { EffectiveMembership, getEffectiveMembership, getEffectiveMembershipTag } from "../../utils/membership";
|
||||
import RoomListLayoutStore from "./RoomListLayoutStore";
|
||||
import { MarkedExecution } from "../../utils/MarkedExecution";
|
||||
import { AsyncStoreWithClient } from "../AsyncStoreWithClient";
|
||||
@@ -308,7 +308,7 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> implements
|
||||
public async onDispatchMyMembership(membershipPayload: any): Promise<void> {
|
||||
// TODO: Type out the dispatcher types so membershipPayload is not any
|
||||
const oldMembership = getEffectiveMembership(membershipPayload.oldMembership);
|
||||
const newMembership = getEffectiveMembership(membershipPayload.membership);
|
||||
const newMembership = getEffectiveMembershipTag(membershipPayload.room, membershipPayload.membership);
|
||||
if (oldMembership !== EffectiveMembership.Join && newMembership === EffectiveMembership.Join) {
|
||||
// If we're joining an upgraded room, we'll want to make sure we don't proliferate
|
||||
// the dead room in the list.
|
||||
|
||||
@@ -30,7 +30,12 @@ import {
|
||||
ListAlgorithm,
|
||||
SortAlgorithm,
|
||||
} from "./models";
|
||||
import { EffectiveMembership, getEffectiveMembership, splitRoomsByMembership } from "../../../utils/membership";
|
||||
import {
|
||||
EffectiveMembership,
|
||||
getEffectiveMembership,
|
||||
getEffectiveMembershipTag,
|
||||
splitRoomsByMembership,
|
||||
} from "../../../utils/membership";
|
||||
import { OrderingAlgorithm } from "./list-ordering/OrderingAlgorithm";
|
||||
import { getListAlgorithmInstance } from "./list-ordering";
|
||||
import { VisibilityProvider } from "../filters/VisibilityProvider";
|
||||
@@ -543,8 +548,9 @@ export class Algorithm extends EventEmitter {
|
||||
public getTagsForRoom(room: Room): TagID[] {
|
||||
const tags: TagID[] = [];
|
||||
|
||||
const membership = getEffectiveMembership(room.getMyMembership());
|
||||
if (!membership) return []; // peeked room has no tags
|
||||
if (!getEffectiveMembership(room.getMyMembership())) return []; // peeked room has no tags
|
||||
|
||||
const membership = getEffectiveMembershipTag(room);
|
||||
|
||||
if (membership === EffectiveMembership.Invite) {
|
||||
tags.push(DefaultTagID.Invite);
|
||||
|
||||
Reference in New Issue
Block a user