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

Commit

Permalink
Fix Prettier errors that slipped past CI (#9741)
Browse files Browse the repository at this point in the history
  • Loading branch information
duxovni authored Dec 12, 2022
1 parent d835721 commit 43f1758
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/utils/EventUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import defaultDispatcher from "../dispatcher/dispatcher";
import { TimelineRenderingType } from "../contexts/RoomContext";
import { launchPollEditor } from "../components/views/messages/MPollBody";
import { Action } from "../dispatcher/actions";
import { ViewRoomPayload } from '../dispatcher/payloads/ViewRoomPayload';
import { ViewRoomPayload } from "../dispatcher/payloads/ViewRoomPayload";

/**
* Returns whether an event should allow actions like reply, reactions, edit, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import { MatrixEvent } from "matrix-js-sdk/src/matrix";

import { VoiceBroadcastInfoEventType, VoiceBroadcastInfoState } from "..";

export const shouldDisplayAsVoiceBroadcastStoppedText = (event: MatrixEvent): boolean => (
event.getType() === VoiceBroadcastInfoEventType
&& event.getContent()?.state === VoiceBroadcastInfoState.Stopped
&& !event.isRedacted()
);
export const shouldDisplayAsVoiceBroadcastStoppedText = (event: MatrixEvent): boolean =>
event.getType() === VoiceBroadcastInfoEventType &&
event.getContent()?.state === VoiceBroadcastInfoState.Stopped &&
!event.isRedacted();
24 changes: 9 additions & 15 deletions src/voice-broadcast/utils/textForVoiceBroadcastStoppedEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,27 @@ import { highlightEvent } from "../../utils/EventUtils";
import { getSenderName } from "../../TextForEvent";
import { _t } from "../../languageHandler";

export const textForVoiceBroadcastStoppedEvent = (event: MatrixEvent): () => ReactNode => {
export const textForVoiceBroadcastStoppedEvent = (event: MatrixEvent): (() => ReactNode) => {
return (): ReactNode => {
const ownUserId = MatrixClientPeg.get()?.getUserId();
const startEventId = event.getRelation()?.event_id;
const roomId = event.getRoomId();

const templateTags = {
a: (text: string) => startEventId && roomId
? (
<AccessibleButton
kind="link_inline"
onClick={() => highlightEvent(roomId, startEventId)}
>
{ text }
a: (text: string) =>
startEventId && roomId ? (
<AccessibleButton kind="link_inline" onClick={() => highlightEvent(roomId, startEventId)}>
{text}
</AccessibleButton>
)
: text,
) : (
text
),
};

if (ownUserId && ownUserId === event.getSender()) {
return _t("You ended a <a>voice broadcast</a>", {}, templateTags);
}

return _t(
"%(senderName)s ended a <a>voice broadcast</a>",
{ senderName: getSenderName(event) },
templateTags,
);
return _t("%(senderName)s ended a <a>voice broadcast</a>", { senderName: getSenderName(event) }, templateTags);
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

import React from "react";
import { render, RenderResult, screen } from "@testing-library/react";
import userEvent from '@testing-library/user-event';
import userEvent from "@testing-library/user-event";
import { mocked } from "jest-mock";
import { MatrixClient, RelationType } from "matrix-js-sdk/src/matrix";

Expand Down Expand Up @@ -48,7 +48,7 @@ describe("textForVoiceBroadcastStoppedEvent", () => {
};
}

return render(<div>{ textForVoiceBroadcastStoppedEvent(event)() }</div>);
return render(<div>{textForVoiceBroadcastStoppedEvent(event)()}</div>);
};

beforeEach(() => {
Expand Down

0 comments on commit 43f1758

Please sign in to comment.