Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

MessageComposerButtons: code cleanup, move buttons out of dropdown #8930

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions src/components/views/rooms/MessageComposerButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,21 @@ const MessageComposerButtons: React.FC<IProps> = (props: IProps) => {
];
moreButtons = [
uploadButton(), // props passed via UploadButtonContext
showStickersButton(props),
stickersButton(props),
voiceRecordingButton(props, narrow),
props.showPollsButton && pollButton(room, props.relation),
showLocationButton(props, room, roomId, matrixClient),
props.showLocationButton && locationButton(props, room, roomId, matrixClient),
];
} else {
mainButtons = [
emojiButton(props),
stickersButton(props),
voiceRecordingButton(props, narrow),
uploadButton(), // props passed via UploadButtonContext
];
moreButtons = [
showStickersButton(props),
voiceRecordingButton(props, narrow),
props.showPollsButton && pollButton(room, props.relation),
showLocationButton(props, room, roomId, matrixClient),
locationButton(props, room, roomId, matrixClient),
];
}

Expand Down Expand Up @@ -265,7 +265,7 @@ const UploadButton = () => {
/>;
};

function showStickersButton(props: IProps): ReactElement {
function stickersButton(props: IProps): ReactElement {
return (
props.showStickersButton
? <CollapsibleButton
Expand Down Expand Up @@ -357,22 +357,20 @@ class PollButton extends React.PureComponent<IPollButtonProps> {
}
}

function showLocationButton(
function locationButton(
props: IProps,
room: Room,
roomId: string,
matrixClient: MatrixClient,
): ReactElement {
return (
props.showLocationButton
? <LocationButton
key="location"
roomId={roomId}
relation={props.relation}
sender={room.getMember(matrixClient.getUserId())}
menuPosition={props.menuPosition}
/>
: null
<LocationButton
key="location"
roomId={roomId}
relation={props.relation}
sender={room.getMember(matrixClient.getUserId())}
menuPosition={props.menuPosition}
/>
);
}

Expand Down
6 changes: 4 additions & 2 deletions test/components/views/rooms/MessageComposerButtons-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ describe("MessageComposerButtons", () => {

expect(buttonLabels(buttons)).toEqual([
"Emoji",
"Sticker",
"Voice Message",
"Attachment",
"More options",
]);
Expand All @@ -73,11 +75,11 @@ describe("MessageComposerButtons", () => {

expect(buttonLabels(buttons)).toEqual([
"Emoji",
"Sticker",
"Voice Message",
"Attachment",
"More options",
[
"Sticker",
"Voice Message",
"Poll",
"Location",
],
Expand Down