Extract voice broadcast header (#9393)
This commit is contained in:
parent
19bc3f1d9a
commit
533eda2273
14 changed files with 318 additions and 79 deletions
|
@ -29,6 +29,7 @@ const iconTypeMap = new Map([
|
|||
export enum IconColour {
|
||||
Accent = "accent",
|
||||
LiveBadge = "live-badge",
|
||||
CompoundSecondaryContent = "compound-secondary-content",
|
||||
}
|
||||
|
||||
export enum IconSize {
|
||||
|
|
|
@ -637,6 +637,7 @@
|
|||
"See <b>%(msgtype)s</b> messages posted to this room": "See <b>%(msgtype)s</b> messages posted to this room",
|
||||
"See <b>%(msgtype)s</b> messages posted to your active room": "See <b>%(msgtype)s</b> messages posted to your active room",
|
||||
"Live": "Live",
|
||||
"Voice broadcast": "Voice broadcast",
|
||||
"Cannot reach homeserver": "Cannot reach homeserver",
|
||||
"Ensure you have a stable internet connection, or get in touch with the server admin": "Ensure you have a stable internet connection, or get in touch with the server admin",
|
||||
"Your %(brand)s is misconfigured": "Your %(brand)s is misconfigured",
|
||||
|
@ -1850,7 +1851,6 @@
|
|||
"Emoji": "Emoji",
|
||||
"Hide stickers": "Hide stickers",
|
||||
"Sticker": "Sticker",
|
||||
"Voice broadcast": "Voice broadcast",
|
||||
"Voice Message": "Voice Message",
|
||||
"You do not have permission to start polls in this room.": "You do not have permission to start polls in this room.",
|
||||
"Poll": "Poll",
|
||||
|
|
|
@ -46,13 +46,10 @@ export const VoiceBroadcastBody: React.FC<IBodyProps> = ({ mxEvent }) => {
|
|||
recording.stop();
|
||||
};
|
||||
|
||||
const senderId = mxEvent.getSender();
|
||||
const sender = mxEvent.sender;
|
||||
return <VoiceBroadcastRecordingBody
|
||||
onClick={stopVoiceBroadcast}
|
||||
live={recordingState === VoiceBroadcastInfoState.Started}
|
||||
member={sender}
|
||||
userId={senderId}
|
||||
title={`${sender?.name ?? senderId} • ${room.name}`}
|
||||
sender={mxEvent.sender}
|
||||
roomName={room.name}
|
||||
/>;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
Copyright 2022 The Matrix.org Foundation C.I.C.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import MemberAvatar from "../../../components/views/avatars/MemberAvatar";
|
||||
import { LiveBadge } from "../..";
|
||||
import { Icon, IconColour, IconType } from "../../../components/atoms/Icon";
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
||||
interface VoiceBroadcastHeaderProps {
|
||||
live: boolean;
|
||||
sender: RoomMember;
|
||||
roomName: string;
|
||||
showBroadcast?: boolean;
|
||||
}
|
||||
|
||||
export const VoiceBroadcastHeader: React.FC<VoiceBroadcastHeaderProps> = ({
|
||||
live,
|
||||
sender,
|
||||
roomName,
|
||||
showBroadcast = false,
|
||||
}) => {
|
||||
const broadcast = showBroadcast
|
||||
? <div className="mx_VoiceBroadcastHeader_line">
|
||||
<Icon type={IconType.Live} colour={IconColour.CompoundSecondaryContent} />
|
||||
{ _t("Voice broadcast") }
|
||||
</div>
|
||||
: null;
|
||||
const liveBadge = live ? <LiveBadge /> : null;
|
||||
return <div className="mx_VoiceBroadcastHeader">
|
||||
<MemberAvatar member={sender} fallbackUserId={sender.userId} />
|
||||
<div className="mx_VoiceBroadcastHeader_content">
|
||||
<div className="mx_VoiceBroadcastHeader_sender">
|
||||
{ sender.name }
|
||||
</div>
|
||||
<div className="mx_VoiceBroadcastHeader_room">
|
||||
{ roomName }
|
||||
</div>
|
||||
{ broadcast }
|
||||
</div>
|
||||
{ liveBadge }
|
||||
</div>;
|
||||
};
|
|
@ -17,40 +17,31 @@ limitations under the License.
|
|||
import React, { MouseEventHandler } from "react";
|
||||
import { RoomMember } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { LiveBadge } from "../..";
|
||||
import MemberAvatar from "../../../components/views/avatars/MemberAvatar";
|
||||
import { VoiceBroadcastHeader } from "../..";
|
||||
|
||||
interface VoiceBroadcastRecordingBodyProps {
|
||||
live: boolean;
|
||||
member: RoomMember;
|
||||
onClick: MouseEventHandler<HTMLDivElement>;
|
||||
title: string;
|
||||
userId: string;
|
||||
roomName: string;
|
||||
sender: RoomMember;
|
||||
}
|
||||
|
||||
export const VoiceBroadcastRecordingBody: React.FC<VoiceBroadcastRecordingBodyProps> = ({
|
||||
live,
|
||||
member,
|
||||
onClick,
|
||||
title,
|
||||
userId,
|
||||
roomName,
|
||||
sender,
|
||||
}) => {
|
||||
const liveBadge = live
|
||||
? <LiveBadge />
|
||||
: null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="mx_VoiceBroadcastRecordingBody"
|
||||
onClick={onClick}
|
||||
>
|
||||
<MemberAvatar member={member} fallbackUserId={userId} />
|
||||
<div className="mx_VoiceBroadcastRecordingBody_content">
|
||||
<div className="mx_VoiceBroadcastRecordingBody_title">
|
||||
{ title }
|
||||
</div>
|
||||
</div>
|
||||
{ liveBadge }
|
||||
<VoiceBroadcastHeader
|
||||
live={live}
|
||||
sender={sender}
|
||||
roomName={roomName}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -24,6 +24,7 @@ import { RelationType } from "matrix-js-sdk/src/matrix";
|
|||
export * from "./audio/VoiceBroadcastRecorder";
|
||||
export * from "./components/VoiceBroadcastBody";
|
||||
export * from "./components/atoms/LiveBadge";
|
||||
export * from "./components/atoms/VoiceBroadcastHeader";
|
||||
export * from "./components/molecules/VoiceBroadcastRecordingBody";
|
||||
export * from "./models/VoiceBroadcastRecording";
|
||||
export * from "./stores/VoiceBroadcastRecordingsStore";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue