From 9f2ccdf913dce10170a7d2465a2f97ac0936d77e Mon Sep 17 00:00:00 2001
From: Half-Shot
Date: Wed, 4 Dec 2019 15:02:36 +0000
Subject: [PATCH] Add support for displaying avatars and links in bridge info
---
.../settings/tabs/room/BridgeSettingsTab.js | 39 +++++++++++++++++--
1 file changed, 35 insertions(+), 4 deletions(-)
diff --git a/src/components/views/settings/tabs/room/BridgeSettingsTab.js b/src/components/views/settings/tabs/room/BridgeSettingsTab.js
index 732d7b2947..459f11277c 100644
--- a/src/components/views/settings/tabs/room/BridgeSettingsTab.js
+++ b/src/components/views/settings/tabs/room/BridgeSettingsTab.js
@@ -20,6 +20,8 @@ import {_t} from "../../../../../languageHandler";
import MatrixClientPeg from "../../../../../MatrixClientPeg";
import Pill from "../../../elements/Pill";
import {makeUserPermalink} from "../../../../../utils/permalinks/Permalinks";
+import BaseAvatar from "../../../avatars/BaseAvatar";
+import { ContentRepo } from "matrix-js-sdk";
const BRIDGE_EVENT_TYPES = [
"uk.half-shot.bridge",
@@ -47,9 +49,10 @@ export default class BridgeSettingsTab extends React.Component {
if (!content || !content.channel || !content.protocol) {
return null;
}
+ const { channel, network } = content;
const protocolName = content.protocol.displayname || content.protocol.id;
- const channelName = content.channel.displayname || content.channel.id;
- const networkName = content.network ? " on " + (content.network.displayname || content.network.id) : "";
+ const channelName = channel.displayname || channel.id;
+ const networkName = network ? network.displayname || network.id : "";
let status = null;
if (content.status === "active") {
status = ( Status: Active
);
@@ -78,13 +81,41 @@ export default class BridgeSettingsTab extends React.Component {
/> bot user.
);
+ const channelLink = channel.external_url ? ({channelName}) : channelName;
+ const networkLink = network && network.external_url ? ({networkName})
+ : networkName;
+
const chanAndNetworkInfo = (
- Bridged into {channelName}{networkName}, on {protocolName}
+ Bridged into {channelLink} {networkLink}, on {protocolName}
);
+ let networkIcon = null;
+ if (networkName && network.avatar) {
+ const avatarUrl = ContentRepo.getHttpUriForMxc(
+ MatrixClientPeg.get().getHomeserverUrl(),
+ network.avatar, 32, 32, "crop",
+ );
+ networkIcon = ;
+ }
+
+ let channelIcon = null;
+ if (channel.avatar) {
+ const avatarUrl = ContentRepo.getHttpUriForMxc(
+ MatrixClientPeg.get().getHomeserverUrl(),
+ channel.avatar, 32, 32, "crop",
+ );
+ console.log(channel.avatar);
+ channelIcon = ;
+ }
+
return (
-
{channelName}{networkName} ({protocolName})
+
{channelIcon} {channelName} {networkName ? ` on ${networkName}` : ""} {networkIcon}
+
Connected via {protocolName}
{status}
{creator}