Remove dead code on favourite and people metaspaces (#34187)

* Remove unused Favourites and People metaspaces

* Update existing tests

* Update snapshots

* Update i18n lang
This commit is contained in:
Florian Duros
2026-07-08 14:20:09 +00:00
committed by GitHub
parent 67a20c57a3
commit d041669031
14 changed files with 32 additions and 762 deletions
@@ -35,7 +35,6 @@ import {
RoomIcon,
SpaceIcon,
UserProfileIcon,
FavouriteIcon,
HomeIcon,
GroupIcon,
CloseIcon,
@@ -156,10 +155,6 @@ function metaspaceToIcon(key: MetaSpace): JSX.Element | undefined {
switch (key) {
case MetaSpace.Home:
return <HomeIcon />;
case MetaSpace.Favourites:
return <FavouriteIcon />;
case MetaSpace.People:
return <UserProfileIcon />;
case MetaSpace.Orphans:
return <RoomIcon />;
}
@@ -34,14 +34,7 @@ export const onMetaSpaceChangeFactory =
PosthogTrackers.trackInteraction(
interactionName,
e,
[
MetaSpace.Home,
null,
MetaSpace.Favourites,
MetaSpace.People,
MetaSpace.Orphans,
MetaSpace.VideoRooms,
].indexOf(metaSpace),
[MetaSpace.Home, null, MetaSpace.Orphans, MetaSpace.VideoRooms].indexOf(metaSpace),
);
};
@@ -25,11 +25,9 @@ import { DragDropContext, Draggable, Droppable, type DroppableProvidedProps } fr
import classNames from "classnames";
import { type Room } from "matrix-js-sdk/src/matrix";
import {
FavouriteSolidIcon,
HomeSolidIcon,
RoomIcon,
VideoCallSolidIcon,
UserProfileSolidIcon,
PlusIcon,
ChevronRightIcon,
} from "@vector-im/compound-design-tokens/assets/web/icons";
@@ -178,34 +176,6 @@ const HomeButton: React.FC<MetaSpaceButtonProps> = ({ selected, isPanelCollapsed
);
};
const FavouritesButton: React.FC<MetaSpaceButtonProps> = ({ selected, isPanelCollapsed }) => {
return (
<MetaSpaceButton
spaceKey={MetaSpace.Favourites}
selected={selected}
isPanelCollapsed={isPanelCollapsed}
label={getMetaSpaceName(MetaSpace.Favourites)}
notificationState={SpaceStore.instance.getNotificationState(MetaSpace.Favourites)}
size="32px"
icon={<FavouriteSolidIcon />}
/>
);
};
const PeopleButton: React.FC<MetaSpaceButtonProps> = ({ selected, isPanelCollapsed }) => {
return (
<MetaSpaceButton
spaceKey={MetaSpace.People}
selected={selected}
isPanelCollapsed={isPanelCollapsed}
label={getMetaSpaceName(MetaSpace.People)}
notificationState={SpaceStore.instance.getNotificationState(MetaSpace.People)}
size="32px"
icon={<UserProfileSolidIcon />}
/>
);
};
const OrphansButton: React.FC<MetaSpaceButtonProps> = ({ selected, isPanelCollapsed }) => {
return (
<MetaSpaceButton
@@ -286,8 +256,6 @@ const CreateSpaceButton: React.FC<Pick<IInnerSpacePanelProps, "isPanelCollapsed"
const metaSpaceComponentMap: Record<MetaSpace, typeof HomeButton> = {
[MetaSpace.Home]: HomeButton,
[MetaSpace.Favourites]: FavouritesButton,
[MetaSpace.People]: PeopleButton,
[MetaSpace.Orphans]: OrphansButton,
[MetaSpace.VideoRooms]: VideoRoomsButton,
};
-1
View File
@@ -480,7 +480,6 @@
"encrypted": "Encrypted",
"error": "Error",
"faq": "FAQ",
"favourites": "Favourites",
"feedback": "Feedback",
"filter_results": "Filter results",
"forward_message": "Forward message",
@@ -134,8 +134,6 @@ describe("SpaceStore", () => {
await SettingsStore.setValue("Spaces.enabledMetaSpaces", null, SettingLevel.DEVICE, {
[MetaSpace.Home]: true,
[MetaSpace.Favourites]: true,
[MetaSpace.People]: true,
[MetaSpace.Orphans]: true,
});
@@ -444,12 +442,6 @@ describe("SpaceStore", () => {
expect(store.isRoomInSpace(MetaSpace.Home, room1)).toBeTruthy();
});
it("people space does contain people even if they are also shown in a space", async () => {
expect(store.isRoomInSpace(MetaSpace.People, dm1)).toBeTruthy();
expect(store.isRoomInSpace(MetaSpace.People, dm2)).toBeTruthy();
expect(store.isRoomInSpace(MetaSpace.People, dm3)).toBeTruthy();
});
it("orphans space does contain orphans even if they are also shown in all rooms", async () => {
await setShowAllRooms(true);
expect(store.isRoomInSpace(MetaSpace.Orphans, orphan1)).toBeTruthy();
@@ -1259,8 +1251,6 @@ describe("SpaceStore", () => {
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
expect(SpaceStore.instance.isRoomInSpace(space1, room1)).toBeTruthy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Home, room1)).toBeFalsy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Favourites, room1)).toBeFalsy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.People, room1)).toBeFalsy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Orphans, room1)).toBeFalsy();
// receive room invite
@@ -1273,8 +1263,6 @@ describe("SpaceStore", () => {
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
expect(SpaceStore.instance.isRoomInSpace(space1, room2)).toBeTruthy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Home, room2)).toBeTruthy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Favourites, room2)).toBeFalsy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.People, room2)).toBeFalsy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Orphans, room2)).toBeFalsy();
// start DM in space
@@ -1314,8 +1302,6 @@ describe("SpaceStore", () => {
expect(SpaceStore.instance.spacePanelSpaces).toStrictEqual([rootSpace]);
expect(SpaceStore.instance.isRoomInSpace(space1, dm1)).toBeTruthy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Home, dm1)).toBeTruthy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Favourites, dm1)).toBeFalsy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.People, dm1)).toBeTruthy();
expect(SpaceStore.instance.isRoomInSpace(MetaSpace.Orphans, dm1)).toBeFalsy();
// join subspace
+8 -63
View File
@@ -29,7 +29,6 @@ import SettingsStore from "../../settings/SettingsStore";
import DMRoomMap from "../../utils/DMRoomMap";
import { SpaceNotificationState } from "../notifications/SpaceNotificationState";
import { RoomNotificationStateStore } from "../notifications/RoomNotificationStateStore";
import { DefaultTagID } from "../room-list-v3/skip-list/tag";
import { EnhancedMap, mapDiff } from "../../utils/maps";
import { setDiff, setHasDiff } from "../../utils/sets";
import { Action } from "../../dispatcher/actions";
@@ -451,7 +450,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
}
// beyond this point we know this is a DM
if (space === MetaSpace.Home || space === MetaSpace.People) {
if (space === MetaSpace.Home) {
// these spaces contain all DMs
return true;
}
@@ -648,13 +647,6 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
this.roomIdsBySpace.delete(MetaSpace.Home);
}
if (enabledMetaSpaces.has(MetaSpace.Favourites)) {
const favourites = visibleRooms.filter((r) => r.tags[DefaultTagID.Favourite]);
this.roomIdsBySpace.set(MetaSpace.Favourites, new Set(favourites.map((r) => r.roomId)));
} else {
this.roomIdsBySpace.delete(MetaSpace.Favourites);
}
// The People metaspace doesn't need maintaining
// Populate the orphans space if the Home space is enabled as it is a superset of it.
@@ -678,18 +670,13 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
const visibleRooms = this.matrixClient.getVisibleRooms(this._msc3946ProcessDynamicPredecessor);
let dmBadgeSpace: MetaSpace | undefined;
// only show badges on dms on the most relevant space if such exists
if (enabledMetaSpaces.has(MetaSpace.People)) {
dmBadgeSpace = MetaSpace.People;
} else if (enabledMetaSpaces.has(MetaSpace.Home)) {
// only show badges on home
if (enabledMetaSpaces.has(MetaSpace.Home)) {
dmBadgeSpace = MetaSpace.Home;
}
if (!spaces) {
spaces = [...this.roomIdsBySpace.keys()];
if (dmBadgeSpace === MetaSpace.People) {
spaces.push(MetaSpace.People);
}
if (enabledMetaSpaces.has(MetaSpace.Home) && !this.allRoomsInHome) {
spaces.push(MetaSpace.Home);
}
@@ -703,10 +690,6 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
// Update NotificationStates
this.getNotificationState(s).setRooms(
visibleRooms.filter((room) => {
if (s === MetaSpace.People) {
return this.isRoomInSpace(MetaSpace.People, room.roomId);
}
if (room.isSpaceRoom() || !flattenedRoomsForSpace.has(room.roomId)) return false;
if (dmBadgeSpace && DMRoomMap.shared().getUserIdForRoomId(room.roomId)) {
@@ -717,10 +700,6 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
}),
);
});
if (dmBadgeSpace !== MetaSpace.People) {
this.notificationStateMap.delete(MetaSpace.People);
}
};
private showInHomeSpace = (room: Room): boolean => {
@@ -885,13 +864,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
this.switchSpaceIfNeeded();
}
const notificationStatesToUpdate = [...changeSet];
// We update the People metaspace even if we didn't detect any changes
// as roomIdsBySpace does not pre-calculate it so we have to assume it could have changed
if (this.enabledMetaSpaces.includes(MetaSpace.People)) {
notificationStatesToUpdate.push(MetaSpace.People);
}
this.updateNotificationStates(notificationStatesToUpdate);
this.updateNotificationStates([...changeSet]);
};
private switchSpaceIfNeeded = (roomId = SDKContextClass.instance.roomViewStore.getRoomId()): void => {
@@ -1070,27 +1043,9 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
if (order !== lastOrder) {
this.notifyIfOrderChanged();
}
} else if (ev.getType() === EventType.Tag) {
// If the room was in favourites and now isn't or the opposite then update its position in the trees
const oldTags = lastEv?.getContent()?.tags || {};
const newTags = ev.getContent()?.tags || {};
if (!!oldTags[DefaultTagID.Favourite] !== !!newTags[DefaultTagID.Favourite]) {
this.onRoomFavouriteChange(room);
}
}
};
private onRoomFavouriteChange(room: Room): void {
if (this.enabledMetaSpaces.includes(MetaSpace.Favourites)) {
if (room.tags[DefaultTagID.Favourite]) {
this.roomIdsBySpace.get(MetaSpace.Favourites)?.add(room.roomId);
} else {
this.roomIdsBySpace.get(MetaSpace.Favourites)?.delete(room.roomId);
}
this.emit(MetaSpace.Favourites);
}
}
private onRoomDmChange(room: Room, isDm: boolean): void {
const enabledMetaSpaces = new Set(this.enabledMetaSpaces);
@@ -1105,10 +1060,6 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
this.emit(MetaSpace.Home);
}
if (enabledMetaSpaces.has(MetaSpace.People)) {
this.emit(MetaSpace.People);
}
if (enabledMetaSpaces.has(MetaSpace.Orphans) || enabledMetaSpaces.has(MetaSpace.Home)) {
if (isDm && this.roomIdsBySpace.get(MetaSpace.Orphans)?.delete(room.roomId)) {
this.emit(MetaSpace.Orphans);
@@ -1204,8 +1155,6 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
const enabled = new Set(this.enabledMetaSpaces);
PosthogAnalytics.instance.setProperty("WebMetaSpaceHomeEnabled", enabled.has(MetaSpace.Home));
PosthogAnalytics.instance.setProperty("WebMetaSpaceHomeAllRooms", this.allRoomsInHome);
PosthogAnalytics.instance.setProperty("WebMetaSpacePeopleEnabled", enabled.has(MetaSpace.People));
PosthogAnalytics.instance.setProperty("WebMetaSpaceFavouritesEnabled", enabled.has(MetaSpace.Favourites));
PosthogAnalytics.instance.setProperty("WebMetaSpaceOrphansEnabled", enabled.has(MetaSpace.Orphans));
}
@@ -1292,13 +1241,9 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
const newValue = SettingsStore.getValue("Spaces.enabledMetaSpaces");
const enabledMetaSpaces = metaSpaceOrder.filter((k) => newValue[k]);
if (arrayHasDiff(this._enabledMetaSpaces, enabledMetaSpaces)) {
const hadPeopleOrHomeEnabled = this.enabledMetaSpaces.some((s) => {
return s === MetaSpace.Home || s === MetaSpace.People;
});
const hadHomeEnabled = this.enabledMetaSpaces.some((s) => s === MetaSpace.Home);
this._enabledMetaSpaces = enabledMetaSpaces;
const hasPeopleOrHomeEnabled = this.enabledMetaSpaces.some((s) => {
return s === MetaSpace.Home || s === MetaSpace.People;
});
const hasHomeEnabled = this.enabledMetaSpaces.some((s) => s === MetaSpace.Home);
// if a metaspace currently being viewed was removed, go to another one
if (isMetaSpace(this.activeSpace) && !newValue[this.activeSpace]) {
@@ -1306,7 +1251,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
}
this.rebuildMetaSpaces();
if (hadPeopleOrHomeEnabled !== hasPeopleOrHomeEnabled) {
if (hadHomeEnabled !== hasHomeEnabled) {
// in this case we have to rebuild everything as DM badges will move to/from real spaces
this.updateNotificationStates();
} else {
@@ -1323,7 +1268,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<EmptyObject> {
if (payload.roomId) {
// getSpaceFilteredUserIds will return the appropriate value
this.emit(payload.roomId);
if (!this.enabledMetaSpaces.some((s) => s === MetaSpace.Home || s === MetaSpace.People)) {
if (!this.enabledMetaSpaces.some((s) => s === MetaSpace.Home)) {
this.updateNotificationStates([payload.roomId]);
}
}
+1 -13
View File
@@ -21,8 +21,6 @@ export const UPDATE_SUGGESTED_ROOMS = Symbol("suggested-rooms");
export enum MetaSpace {
Home = "home-space",
Favourites = "favourites-space",
People = "people-space",
Orphans = "orphans-space",
VideoRooms = "video-rooms-space",
}
@@ -31,10 +29,6 @@ export const getMetaSpaceName = (spaceKey: MetaSpace, allRoomsInHome = false): s
switch (spaceKey) {
case MetaSpace.Home:
return allRoomsInHome ? _t("common|all_chats") : _t("common|home");
case MetaSpace.Favourites:
return _t("common|favourites");
case MetaSpace.People:
return _t("common|people");
case MetaSpace.Orphans:
return _t("common|orphan_rooms");
case MetaSpace.VideoRooms:
@@ -57,11 +51,5 @@ export interface ISuggestedRoom extends HierarchyRoom {
}
export function isMetaSpace(spaceKey?: SpaceKey): spaceKey is MetaSpace {
return (
spaceKey === MetaSpace.Home ||
spaceKey === MetaSpace.Favourites ||
spaceKey === MetaSpace.People ||
spaceKey === MetaSpace.Orphans ||
spaceKey === MetaSpace.VideoRooms
);
return spaceKey === MetaSpace.Home || spaceKey === MetaSpace.Orphans || spaceKey === MetaSpace.VideoRooms;
}