mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-21 21:01:29 +01:00
Audio: Fix waveform for silent and waveformless voices (#1542)
This commit is contained in:
parent
7620774dc4
commit
bd914a9024
@ -18,7 +18,7 @@ import {
|
||||
isMessageLocal,
|
||||
isOwnMessage,
|
||||
} from '../../modules/helpers';
|
||||
import { renderWaveform } from './helpers/waveform';
|
||||
import { MAX_EMPTY_WAVEFORM_POINTS, renderWaveform } from './helpers/waveform';
|
||||
import buildClassName from '../../util/buildClassName';
|
||||
import renderText from './helpers/renderText';
|
||||
import { getFileSizeString } from './helpers/documentInfo';
|
||||
@ -460,7 +460,10 @@ function useWaveformCanvas(
|
||||
|
||||
const { waveform, duration } = voice;
|
||||
if (!waveform) {
|
||||
return undefined;
|
||||
return {
|
||||
data: new Array(Math.min(duration, MAX_EMPTY_WAVEFORM_POINTS)).fill(0),
|
||||
peak: 0,
|
||||
};
|
||||
}
|
||||
|
||||
const durationFactor = Math.min(duration / AVG_VOICE_DURATION, 1);
|
||||
@ -472,7 +475,8 @@ function useWaveformCanvas(
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
if (!canvas || !spikes || !peak) {
|
||||
|
||||
if (!canvas || !spikes || peak === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ type IWaveformProps = {
|
||||
progressFillStyle: string;
|
||||
};
|
||||
|
||||
export const MAX_EMPTY_WAVEFORM_POINTS = 30;
|
||||
const SPIKE_WIDTH = 2;
|
||||
const SPIKE_STEP = 4;
|
||||
const SPIKE_RADIUS = 1;
|
||||
|
@ -703,6 +703,8 @@
|
||||
}
|
||||
|
||||
.forwarded-message {
|
||||
.message-content.contact &,
|
||||
.message-content.voice &,
|
||||
.message-content.poll & {
|
||||
// MessageOutgoingStatus's icon needs more space
|
||||
margin-bottom: 0.5rem;
|
||||
|
Loading…
x
Reference in New Issue
Block a user