Watcha op373 add permalink for rooms (#40)
* feat: add permalink for rooms * feat: add a navigation context to avoid multiple tabs * fix: use a ref for refetch as it should not induce rendering when it changesdevelop
parent
c7899019e2
commit
dd6a906aed
@ -0,0 +1,33 @@ |
||||
import React from "react"; |
||||
import { useTranslation } from "react-i18next"; |
||||
|
||||
import { useMatrixClientContext } from "./contexts"; |
||||
|
||||
import boxArrowUpRight from "./images/box-arrow-up-right.svg"; |
||||
import "./css/RoomPermalink.scss"; |
||||
|
||||
export default ({ roomId }) => { |
||||
const { t } = useTranslation("roomsTab"); |
||||
|
||||
const client = useMatrixClientContext(); |
||||
const rooms = client.getRooms(); |
||||
const isMine = rooms.some(room => room.roomId === roomId); |
||||
|
||||
return isMine ? ( |
||||
<a href={`/app/#/room/${roomId}`} target="room"> |
||||
<img |
||||
className="RoomPermalink" |
||||
src={boxArrowUpRight} |
||||
alt={t("permalink.alt")} |
||||
title={t("permalink.enabled")} |
||||
/> |
||||
</a> |
||||
) : ( |
||||
<img |
||||
className="RoomPermalink RoomPermalink-disabled" |
||||
src={boxArrowUpRight} |
||||
alt={t("permalink.alt")} |
||||
title={t("permalink.disabled")} |
||||
/> |
||||
); |
||||
}; |
||||
@ -0,0 +1,8 @@ |
||||
.RoomPermalink { |
||||
margin-left: 1em; |
||||
margin-right: 1em; |
||||
} |
||||
|
||||
.RoomPermalink-disabled { |
||||
filter: opacity(40%); |
||||
} |
||||
|
After Width: | Height: | Size: 552 B |
Loading…
Reference in new issue