mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-22 05:11:55 +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,
|
isMessageLocal,
|
||||||
isOwnMessage,
|
isOwnMessage,
|
||||||
} from '../../modules/helpers';
|
} from '../../modules/helpers';
|
||||||
import { renderWaveform } from './helpers/waveform';
|
import { MAX_EMPTY_WAVEFORM_POINTS, renderWaveform } from './helpers/waveform';
|
||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
import renderText from './helpers/renderText';
|
import renderText from './helpers/renderText';
|
||||||
import { getFileSizeString } from './helpers/documentInfo';
|
import { getFileSizeString } from './helpers/documentInfo';
|
||||||
@ -460,7 +460,10 @@ function useWaveformCanvas(
|
|||||||
|
|
||||||
const { waveform, duration } = voice;
|
const { waveform, duration } = voice;
|
||||||
if (!waveform) {
|
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);
|
const durationFactor = Math.min(duration / AVG_VOICE_DURATION, 1);
|
||||||
@ -472,7 +475,8 @@ function useWaveformCanvas(
|
|||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const canvas = canvasRef.current;
|
const canvas = canvasRef.current;
|
||||||
if (!canvas || !spikes || !peak) {
|
|
||||||
|
if (!canvas || !spikes || peak === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ type IWaveformProps = {
|
|||||||
progressFillStyle: string;
|
progressFillStyle: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const MAX_EMPTY_WAVEFORM_POINTS = 30;
|
||||||
const SPIKE_WIDTH = 2;
|
const SPIKE_WIDTH = 2;
|
||||||
const SPIKE_STEP = 4;
|
const SPIKE_STEP = 4;
|
||||||
const SPIKE_RADIUS = 1;
|
const SPIKE_RADIUS = 1;
|
||||||
|
@ -703,6 +703,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.forwarded-message {
|
.forwarded-message {
|
||||||
|
.message-content.contact &,
|
||||||
|
.message-content.voice &,
|
||||||
.message-content.poll & {
|
.message-content.poll & {
|
||||||
// MessageOutgoingStatus's icon needs more space
|
// MessageOutgoingStatus's icon needs more space
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user