mirror of
https://github.com/element-hq/element-web
synced 2024-11-24 18:25:49 +03:00
Handle edge cases
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
b94dc2d0e5
commit
255ab49ccb
1 changed files with 25 additions and 3 deletions
|
@ -119,7 +119,29 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
|
|||
} else if (!selectedCommunityId) {
|
||||
MatrixClientPeg.get().getThirdpartyProtocols().then((response) => {
|
||||
this.protocols = response;
|
||||
this.setState({ protocolsLoading: false });
|
||||
const myHomeserver = MatrixClientPeg.getHomeserverName();
|
||||
const lsRoomServer = localStorage.getItem(LAST_SERVER_KEY);
|
||||
const lsInstanceId = localStorage.getItem(LAST_INSTANCE_KEY);
|
||||
const configSevers = SdkConfig.get().roomDirectory?.servers || [];
|
||||
const roomServer = configSevers.includes(lsRoomServer)
|
||||
? lsRoomServer
|
||||
: myHomeserver;
|
||||
const instanceIds = [];
|
||||
if (roomServer === myHomeserver) {
|
||||
Object.values(this.protocols).forEach((protocol) => {
|
||||
protocol.instances.forEach((instance) => instanceIds.push(instance.instance_id));
|
||||
});
|
||||
}
|
||||
const instanceId = (instanceIds.includes(lsInstanceId) || lsInstanceId === ALL_ROOMS)
|
||||
? lsInstanceId
|
||||
: null;
|
||||
|
||||
this.setState({
|
||||
protocolsLoading: false,
|
||||
instanceId: instanceId,
|
||||
roomServer: roomServer,
|
||||
});
|
||||
this.refreshRoomList();
|
||||
}, (err) => {
|
||||
console.warn(`error loading third party protocols: ${err}`);
|
||||
this.setState({ protocolsLoading: false });
|
||||
|
@ -153,8 +175,8 @@ export default class RoomDirectory extends React.Component<IProps, IState> {
|
|||
publicRooms: [],
|
||||
loading: true,
|
||||
error: null,
|
||||
instanceId: localStorage.getItem(LAST_INSTANCE_KEY),
|
||||
roomServer: localStorage.getItem(LAST_SERVER_KEY) || MatrixClientPeg.getHomeserverName(),
|
||||
instanceId: null,
|
||||
roomServer: null,
|
||||
filterString: this.props.initialText || "",
|
||||
selectedCommunityId,
|
||||
communityName: null,
|
||||
|
|
Loading…
Reference in a new issue