mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 12:28:50 +03:00
Stop automatic playback if a non-voice message is encountered
Fixes https://github.com/vector-im/element-web/issues/18850
This commit is contained in:
parent
d7426b9b5b
commit
91d0b55fd0
1 changed files with 9 additions and 4 deletions
|
@ -22,6 +22,7 @@ import { arrayFastClone } from "../utils/arrays";
|
||||||
import { PlaybackManager } from "./PlaybackManager";
|
import { PlaybackManager } from "./PlaybackManager";
|
||||||
import { isVoiceMessage } from "../utils/EventUtils";
|
import { isVoiceMessage } from "../utils/EventUtils";
|
||||||
import RoomViewStore from "../stores/RoomViewStore";
|
import RoomViewStore from "../stores/RoomViewStore";
|
||||||
|
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Audio playback queue management for a given room. This keeps track of where the user
|
* Audio playback queue management for a given room. This keeps track of where the user
|
||||||
|
@ -137,13 +138,17 @@ export class PlaybackQueue {
|
||||||
}
|
}
|
||||||
if (!scanForVoiceMessage) continue;
|
if (!scanForVoiceMessage) continue;
|
||||||
|
|
||||||
// Dev note: This is where we'd break to cause text/non-voice messages to
|
if (!isVoiceMessage(event)) {
|
||||||
// interrupt automatic playback.
|
const evType = event.getType();
|
||||||
|
if (evType !== EventType.RoomMessage && evType !== EventType.Sticker) {
|
||||||
|
continue; // Event can be skipped for automatic playback consideration
|
||||||
|
}
|
||||||
|
break; // Stop automatic playback: next useful event is not a voice message
|
||||||
|
}
|
||||||
|
|
||||||
const isRightType = isVoiceMessage(event);
|
|
||||||
const havePlayback = this.playbacks.has(event.getId());
|
const havePlayback = this.playbacks.has(event.getId());
|
||||||
const isRecentlyCompleted = this.recentFullPlays.has(event.getId());
|
const isRecentlyCompleted = this.recentFullPlays.has(event.getId());
|
||||||
if (isRightType && havePlayback && !isRecentlyCompleted) {
|
if (havePlayback && !isRecentlyCompleted) {
|
||||||
nextEv = event;
|
nextEv = event;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue