mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 01:35:49 +03:00
Hide voice broadcast chunks (#9397)
This commit is contained in:
parent
96213d644b
commit
b871456681
3 changed files with 59 additions and 8 deletions
|
@ -46,6 +46,7 @@ import ViewSourceEvent from "../components/views/messages/ViewSourceEvent";
|
|||
import { shouldDisplayAsBeaconTile } from "../utils/beacon/timeline";
|
||||
import { shouldDisplayAsVoiceBroadcastTile } from "../voice-broadcast/utils/shouldDisplayAsVoiceBroadcastTile";
|
||||
import { ElementCall } from "../models/Call";
|
||||
import { VoiceBroadcastChunkEventType } from "../voice-broadcast";
|
||||
|
||||
// Subset of EventTile's IProps plus some mixins
|
||||
export interface EventTileTypeProps {
|
||||
|
@ -252,6 +253,11 @@ export function pickFactory(
|
|||
return noEventFactoryFactory();
|
||||
}
|
||||
|
||||
if (mxEvent.getContent()[VoiceBroadcastChunkEventType]) {
|
||||
// hide voice broadcast chunks
|
||||
return noEventFactoryFactory();
|
||||
}
|
||||
|
||||
return EVENT_TILE_TYPES.get(evType) ?? noEventFactoryFactory();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ export * from "./utils/shouldDisplayAsVoiceBroadcastTile";
|
|||
export * from "./utils/startNewVoiceBroadcastRecording";
|
||||
|
||||
export const VoiceBroadcastInfoEventType = "io.element.voice_broadcast_info";
|
||||
export const VoiceBroadcastChunkEventType = "io.element.voice_broadcast_chunk";
|
||||
|
||||
export enum VoiceBroadcastInfoState {
|
||||
Started = "started",
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
/*
|
||||
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.
|
||||
|
@ -14,23 +11,70 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { EventType, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { EventType, MatrixClient, MatrixEvent, MsgType } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { JSONEventFactory, pickFactory } from "../../src/events/EventTileFactory";
|
||||
import { createTestClient } from "../test-utils";
|
||||
import { VoiceBroadcastChunkEventType } from "../../src/voice-broadcast";
|
||||
import { createTestClient, mkEvent } from "../test-utils";
|
||||
|
||||
const roomId = "!room:example.com";
|
||||
|
||||
describe("pickFactory", () => {
|
||||
let voiceBroadcastChunkEvent: MatrixEvent;
|
||||
let audioMessageEvent: MatrixEvent;
|
||||
let client: MatrixClient;
|
||||
|
||||
beforeAll(() => {
|
||||
client = createTestClient();
|
||||
voiceBroadcastChunkEvent = mkEvent({
|
||||
event: true,
|
||||
type: EventType.RoomMessage,
|
||||
user: client.getUserId(),
|
||||
room: roomId,
|
||||
content: {
|
||||
msgtype: MsgType.Audio,
|
||||
[VoiceBroadcastChunkEventType]: {},
|
||||
},
|
||||
});
|
||||
audioMessageEvent = mkEvent({
|
||||
event: true,
|
||||
type: EventType.RoomMessage,
|
||||
user: client.getUserId(),
|
||||
room: roomId,
|
||||
content: {
|
||||
msgtype: MsgType.Audio,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("should return JSONEventFactory for a no-op m.room.power_levels event", () => {
|
||||
const cli = createTestClient();
|
||||
const event = new MatrixEvent({
|
||||
type: EventType.RoomPowerLevels,
|
||||
state_key: "",
|
||||
content: {},
|
||||
sender: cli.getUserId(),
|
||||
sender: client.getUserId(),
|
||||
room_id: roomId,
|
||||
});
|
||||
expect(pickFactory(event, cli, true)).toBe(JSONEventFactory);
|
||||
expect(pickFactory(event, client, true)).toBe(JSONEventFactory);
|
||||
});
|
||||
|
||||
describe("when showing hidden events", () => {
|
||||
it("should return a function for a voice broadcast event", () => {
|
||||
expect(pickFactory(voiceBroadcastChunkEvent, client, true)).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
it("should return a function for an audio message event", () => {
|
||||
expect(pickFactory(audioMessageEvent, client, true)).toBeInstanceOf(Function);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when not showing hidden events", () => {
|
||||
it("should return undefined for a voice broadcast event", () => {
|
||||
expect(pickFactory(voiceBroadcastChunkEvent, client, false)).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should return a function for an audio message event", () => {
|
||||
expect(pickFactory(audioMessageEvent, client, false)).toBeInstanceOf(Function);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue