Skip to content

Commit 072bda5

Browse files
Embed - tiny code migrated to react / Share button in the room settings added.
1 parent ca7cefe commit 072bda5

File tree

4 files changed

+92
-60
lines changed

4 files changed

+92
-60
lines changed

info/dev/preparing-changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
- Force Dev Mode option added into the `.env` file.
66
- New room viewer script to mobile.
77
- Mobile css content place fixed.
8+
- Share button in the room settings added.

src/app/molecules/dialog/Dialog.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Dialog({
1313
onAfterOpen = null,
1414
onAfterClose = null,
1515
onRequestClose = null,
16-
children,
16+
children = null,
1717
bodyClass = '',
1818
}) {
1919
useEffect(() => {
@@ -57,7 +57,7 @@ Dialog.propTypes = {
5757
onAfterOpen: PropTypes.func,
5858
onAfterClose: PropTypes.func,
5959
onRequestClose: PropTypes.func,
60-
children: PropTypes.node.isRequired,
60+
children: PropTypes.node,
6161
};
6262

6363
export default Dialog;

src/app/molecules/message/Embed.jsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function Embed({ embed = {}, roomId = null, threadId = null }) {
2323
// URL Ref
2424
const tinyUrl = useRef(null);
2525
const itemEmbed = useRef(null);
26+
const [useVideo, setUseVideo] = useState(false);
2627
const [embedHeight, setEmbedHeight] = useState(null);
2728

2829
const imgType =
@@ -196,26 +197,33 @@ function Embed({ embed = {}, roomId = null, threadId = null }) {
196197
) : null}
197198

198199
{isVideo && typeof imgUrl === 'string' && imgUrl.length > 0 ? (
199-
<div
200-
className="mt-2 ratio ratio-16x9 embed-video"
201-
style={{
202-
backgroundImage: `url('${imgUrl !== defaultVideoAvatar ? mx.mxcUrlToHttp(imgUrl, 2000, 2000) : defaultVideoAvatar}')`,
203-
}}
204-
onClick={(e) => {
205-
$(e.target).replaceWith(
206-
jReact(
207-
<div className="mt-2 ratio ratio-16x9 embed-video enabled">
208-
<embed title={String(embed['og:title'])} src={videoUrl} allowfullscreen="" />
209-
</div>,
210-
),
211-
);
212-
}}
213-
>
200+
!useVideo ? (
214201
<div
215-
className="play-button w-100 h-100"
216-
style={{ backgroundImage: `url('./img/svg/play-circle-fill.svg')` }}
217-
/>
218-
</div>
202+
className="mt-2 ratio ratio-16x9 embed-video"
203+
style={{
204+
backgroundImage: `url('${imgUrl !== defaultVideoAvatar ? mx.mxcUrlToHttp(imgUrl, 2000, 2000) : defaultVideoAvatar}')`,
205+
}}
206+
onClick={() => {
207+
setUseVideo(true);
208+
}}
209+
>
210+
<div
211+
className="play-button w-100 h-100"
212+
style={{ backgroundImage: `url('./img/svg/play-circle-fill.svg')` }}
213+
/>
214+
</div>
215+
) : (
216+
<div className="mt-2 ratio ratio-16x9 embed-video enabled">
217+
<iframe
218+
title={String(embed['og:title'])}
219+
src={videoUrl}
220+
allowFullScreen
221+
frameborder="0"
222+
webkitallowfullscreen="true"
223+
mozallowfullscreen="true"
224+
/>
225+
</div>
226+
)
219227
) : null}
220228
</span>
221229
</div>

src/app/molecules/room-profile/RoomProfile.jsx

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import PropTypes from 'prop-types';
3+
import tinyClipboard from '@src/util/libs/Clipboard';
4+
import { getShareUrl } from '@src/util/tools';
35

46
import { twemojifyReact } from '../../../util/twemojify';
57

@@ -293,50 +295,71 @@ function RoomProfile({ roomId, isSpace }) {
293295
);
294296

295297
// Render Panel
296-
const renderNameAndTopic = () => (
297-
<div
298-
className="emoji-size-fix"
299-
style={{ marginBottom: avatarSrc && canChangeAvatar ? '24px' : '0' }}
300-
>
301-
<div>
302-
<h4 className="d-inline-block m-0 my-1">{twemojifyReact(roomName)}</h4>
303-
304-
{nameCinny.category.length > 0 && (
305-
<div className="d-inline-block m-0 my-1">
306-
<span style={{ marginRight: '8px', marginLeft: '18px' }}>
307-
<RawIcon fa="fa-solid fa-grip-lines-vertical" />
308-
</span>
309-
<span>{twemojifyReact(nameCinny.category)}</span>
310-
</div>
311-
)}
298+
const renderNameAndTopic = () => {
299+
const isAlias = typeof room.getCanonicalAlias() === 'string';
300+
const roomId = room.getCanonicalAlias() || room.roomId;
301+
return (
302+
<div
303+
className="emoji-size-fix"
304+
style={{ marginBottom: avatarSrc && canChangeAvatar ? '24px' : '0' }}
305+
>
306+
<div>
307+
<h4 className="d-inline-block m-0 my-1">{twemojifyReact(roomName)}</h4>
308+
309+
{nameCinny.category.length > 0 && (
310+
<div className="d-inline-block m-0 my-1">
311+
<span style={{ marginRight: '8px', marginLeft: '18px' }}>
312+
<RawIcon fa="fa-solid fa-grip-lines-vertical" />
313+
</span>
314+
<span>{twemojifyReact(nameCinny.category)}</span>
315+
</div>
316+
)}
312317

313-
{nameCinny.index.length > 0 && (
314-
<div className="d-inline-block m-0 my-1">
315-
<span style={{ marginRight: '8px', marginLeft: '8px' }}>
316-
<RawIcon fa="fa-solid fa-grip-lines-vertical" />
317-
</span>
318-
<span>{twemojifyReact(nameCinny.index)}</span>
319-
</div>
320-
)}
318+
{nameCinny.index.length > 0 && (
319+
<div className="d-inline-block m-0 my-1">
320+
<span style={{ marginRight: '8px', marginLeft: '8px' }}>
321+
<RawIcon fa="fa-solid fa-grip-lines-vertical" />
322+
</span>
323+
<span>{twemojifyReact(nameCinny.index)}</span>
324+
</div>
325+
)}
321326

322-
<span> </span>
327+
<span> </span>
323328

324-
{(canChangeName || canChangeTopic) && (
325-
<IconButton
326-
fa="fa-solid fa-pencil"
327-
size="extra-small"
328-
tooltip="Edit"
329-
onClick={() => setIsEditing(true)}
330-
/>
329+
{(canChangeName || canChangeTopic) && (
330+
<IconButton
331+
fa="fa-solid fa-pencil"
332+
size="extra-small"
333+
tooltip="Edit"
334+
onClick={() => setIsEditing(true)}
335+
/>
336+
)}
337+
</div>
338+
339+
<div className="very-small text-gray">
340+
{roomId}
341+
{isAlias ? (
342+
<a
343+
className="ms-1 badge bg-primary text-bg-force noselect"
344+
href="#"
345+
onClick={(event) => {
346+
event.preventDefault();
347+
tinyClipboard.copyText(getShareUrl(roomId));
348+
alert('The share link was successfully copied!', 'Room Viewer');
349+
}}
350+
>
351+
Share
352+
</a>
353+
) : null}
354+
</div>
355+
{roomTopic && (
356+
<div className="very-small text-freedom">
357+
{twemojifyReact(roomTopic, undefined, true)}
358+
</div>
331359
)}
332360
</div>
333-
334-
<div className="very-small text-gray">{room.getCanonicalAlias() || room.roomId}</div>
335-
{roomTopic && (
336-
<div className="very-small text-freedom">{twemojifyReact(roomTopic, undefined, true)}</div>
337-
)}
338-
</div>
339-
);
361+
);
362+
};
340363

341364
// Complete
342365
return (

0 commit comments

Comments
 (0)