Skip to content

Commit

Permalink
UserList -> getUserRooms script fixed. / MutualServers key issue fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminDreasond committed Aug 17, 2024
1 parent 01b925e commit b8ef841
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/app/organisms/profile-viewer/tabs/MutualServers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ function MutualServerRender({ userId, requestClose }) {
{userData.spaces.length > 0 ? (
<>
<div className="small text-gray ms-2 mb-1">Spaces</div>
<ul class="mutual-servers m-0 p-0">
<ul className="mutual-servers m-0 p-0">
{userData.spaces.map((roomId) => {
const room = mx.getRoom(roomId);

return (
<li class="list-group-item">
<li key={`mutual_servers_space_${roomId}`} className="list-group-item">
<RoomSelector
key={`mutual_servers_${roomId}`}
name={room.name}
Expand All @@ -63,12 +63,12 @@ function MutualServerRender({ userId, requestClose }) {
<>
{userData.spaces.length > 0 ? <hr className="mx-0 my-2 border-bg" /> : null}
<div className="small text-gray ms-2 mb-1">Rooms</div>
<ul class="mutual-servers m-0 p-0">
<ul className="mutual-servers m-0 p-0">
{userData.rooms.map((roomId) => {
const room = mx.getRoom(roomId);

return (
<li class="list-group-item">
<li key={`mutual_servers_room_${roomId}`} className="list-group-item">
<RoomSelector
key={`mutual_servers_${roomId}`}
name={room.name}
Expand Down
30 changes: 19 additions & 11 deletions src/client/state/UserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class UserList extends EventEmitter {
this.users = new Map();
this.rooms = new Map();

this._populateRooms();
this.populateRooms();
this._listenEvents();
}

Expand All @@ -27,20 +27,28 @@ class UserList extends EventEmitter {
if (rooms) {
let using = false;
const result = { spaces: [], rooms: [] };
const checked = [];
const { roomList } = initMatrix;

rooms.forEach((roomId) => {
if (roomList.isOrphan(roomId)) {
if (roomList.spaces.has(roomId)) {
using = true;
result.spaces.push(roomId);
} else if (!roomList.directs.has(roomId)) {
using = true;
result.rooms.push(roomId);
const insertRoom = (roomId) => {
if (checked.indexOf(roomId) < 0) {
checked.push(roomId);
if (roomList.isOrphan(roomId)) {
if (roomList.spaces.has(roomId)) {
using = true;
result.spaces.push(roomId);
} else if (!roomList.directs.has(roomId)) {
using = true;
result.rooms.push(roomId);
}
} else {
const moreRooms = roomList.roomIdToParents.get(roomId);
if (moreRooms) moreRooms.forEach((roomId2) => insertRoom(roomId2));
}
}
});
};

rooms.forEach((roomId) => insertRoom(roomId));
if (using) return result;
}
return null;
Expand Down Expand Up @@ -118,7 +126,7 @@ class UserList extends EventEmitter {
});
}

_populateRooms() {
populateRooms() {
const tinyThis = this;
this.matrixClient.getRooms().forEach((room) => {
tinyThis.populateRoom(room);
Expand Down

0 comments on commit b8ef841

Please sign in to comment.