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

Commit

Permalink
First special treatment of space-rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Feb 19, 2021
1 parent 6b3f05a commit 79daf61
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/Avatar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ export function avatarUrlForRoom(room: Room, width: number, height: number, resi
return explicitRoomAvatar;
}

// space rooms cannot be DMs so skip the rest
if (room.isSpaceRoom()) return null;

let otherMember = null;
const otherUserId = DMRoomMap.shared().getUserIdForRoomId(room.roomId);
if (otherUserId) {
Expand Down
1 change: 1 addition & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,7 @@
"%(senderName)s: %(reaction)s": "%(senderName)s: %(reaction)s",
"%(senderName)s: %(stickerName)s": "%(senderName)s: %(stickerName)s",
"Change notification settings": "Change notification settings",
"Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags": "Spaces prototype. Incompatible with Communities, Communities v2 and Custom Tags",
"Render LaTeX maths in messages": "Render LaTeX maths in messages",
"Communities v2 prototypes. Requires compatible homeserver. Highly experimental - use with caution.": "Communities v2 prototypes. Requires compatible homeserver. Highly experimental - use with caution.",
"New spinner design": "New spinner design",
Expand Down
1 change: 1 addition & 0 deletions src/stores/BreadcrumbsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
}

private async appendRoom(room: Room) {
if (room.isSpaceRoom() && SettingsStore.getValue("feature_spaces")) return; // hide space rooms
let updated = false;
const rooms = (this.state.rooms || []).slice(); // cheap clone

Expand Down
18 changes: 10 additions & 8 deletions src/stores/room-list/filters/VisibilityProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {Room} from "matrix-js-sdk/src/models/room";
import CallHandler from "../../../CallHandler";
import { RoomListCustomisations } from "../../../customisations/RoomList";
import VoipUserMapper from "../../../VoipUserMapper";
import SettingsStore from "../../../settings/SettingsStore";

export class VisibilityProvider {
private static internalInstance: VisibilityProvider;
Expand All @@ -37,22 +38,23 @@ export class VisibilityProvider {
}

public isRoomVisible(room: Room): boolean {
let isVisible = true; // Returned at the end of this function
let forced = false; // When true, this function won't bother calling the customisation points

if (
CallHandler.sharedInstance().getSupportsVirtualRooms() &&
VoipUserMapper.sharedInstance().isVirtualRoom(room)
) {
isVisible = false;
forced = true;
return false;
}

// hide space rooms as they'll be shown in the SpacePanel
if (room.isSpaceRoom() && SettingsStore.getValue("feature_spaces")) {
return false;
}

const isVisibleFn = RoomListCustomisations.isRoomVisible;
if (!forced && isVisibleFn) {
isVisible = isVisibleFn(room);
if (isVisibleFn) {
return isVisibleFn(room);
}

return isVisible;
return true; // default
}
}

0 comments on commit 79daf61

Please sign in to comment.