From d74e803fa92f4bca1fb7207e58d21afe3ca9ff7f Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 14 Jul 2020 12:40:48 -0600 Subject: [PATCH 1/2] Remove potential source of room duplication issues This is an estimated fix as the problem cannot be easily identified. We don't appear to need these lines, unlike what the comment implies. --- src/stores/room-list/algorithms/Algorithm.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/stores/room-list/algorithms/Algorithm.ts b/src/stores/room-list/algorithms/Algorithm.ts index 3cf71f1ca8..61e602bfa9 100644 --- a/src/stores/room-list/algorithms/Algorithm.ts +++ b/src/stores/room-list/algorithms/Algorithm.ts @@ -711,11 +711,6 @@ export class Algorithm extends EventEmitter { if (!algorithm) throw new Error(`No algorithm for ${rmTag}`); await algorithm.handleRoomUpdate(room, RoomUpdateCause.RoomRemoved); this.cachedRooms[rmTag] = algorithm.orderedRooms; - - // Later on we won't update the filtered rooms or sticky room for removed - // tags, so do so now. - this.recalculateFilteredRoomsForTag(rmTag); - this.recalculateStickyRoom(rmTag); } for (const addTag of diff.added) { if (!window.mx_QuietRoomListLogging) { From b19ae3ac93465400c6ea04114b240126d3775426 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 14 Jul 2020 12:49:29 -0600 Subject: [PATCH 2/2] Turn previews on for DMs and ensure they get rendered --- src/components/views/rooms/RoomTile2.tsx | 7 +++++++ src/stores/room-list/ListLayout.ts | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/RoomTile2.tsx b/src/components/views/rooms/RoomTile2.tsx index fe6a19f2ed..6a76e6788e 100644 --- a/src/components/views/rooms/RoomTile2.tsx +++ b/src/components/views/rooms/RoomTile2.tsx @@ -54,6 +54,7 @@ import defaultDispatcher from "../../../dispatcher/dispatcher"; import {ActionPayload} from "../../../dispatcher/payloads"; import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore"; import { NotificationState } from "../../../stores/notifications/NotificationState"; +import { UPDATE_EVENT } from "../../../stores/AsyncStore"; // TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14367 @@ -128,6 +129,7 @@ export default class RoomTile2 extends React.Component { }; ActiveRoomObserver.addListener(this.props.room.roomId, this.onActiveRoomUpdate); + MessagePreviewStore.instance.on(UPDATE_EVENT, this.onPreviewUpdated); this.dispatcherRef = defaultDispatcher.register(this.onAction); } @@ -150,9 +152,14 @@ export default class RoomTile2 extends React.Component { if (this.props.room) { ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate); } + MessagePreviewStore.instance.off(UPDATE_EVENT, this.onPreviewUpdated); defaultDispatcher.unregister(this.dispatcherRef); } + private onPreviewUpdated = () => { + this.forceUpdate(); // we don't track the preview in state, so just re-render + }; + private onAction = (payload: ActionPayload) => { if (payload.action === "view_room" && payload.room_id === this.props.room.roomId && payload.show_room_tile) { setImmediate(() => { diff --git a/src/stores/room-list/ListLayout.ts b/src/stores/room-list/ListLayout.ts index caf2e92bd1..2bbf7f471c 100644 --- a/src/stores/room-list/ListLayout.ts +++ b/src/stores/room-list/ListLayout.ts @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { TagID } from "./models"; +import { DefaultTagID, TagID } from "./models"; +import { isNullOrUndefined } from "matrix-js-sdk/src/utils"; const TILE_HEIGHT_PX = 44; @@ -26,7 +27,7 @@ interface ISerializedListLayout { export class ListLayout { private _n = 0; - private _previews = false; + private _previews: boolean | null = null; private _collapsed = false; constructor(public readonly tagId: TagID) { @@ -50,7 +51,12 @@ export class ListLayout { } public get showPreviews(): boolean { - return this._previews; + if (!isNullOrUndefined(this._previews)) { + return this._previews; + } + + // Turn it on for DMs by default, but not for other rooms + return this.tagId === DefaultTagID.DM; } public set showPreviews(v: boolean) {