Downloads (Follow-up) (#1510)

This commit is contained in:
Alexander Zinchuk 2021-10-22 02:24:39 +03:00
parent f32195571e
commit 74a0f96b6c
4 changed files with 5 additions and 4 deletions

View File

@ -88,7 +88,7 @@ const Photo: FC<OwnProps> = ({
isUploading, isTransferring, transferProgress, isUploading, isTransferring, transferProgress,
} = getMediaTransferState( } = getMediaTransferState(
message, message,
uploadProgress || isDownloading ? downloadProgress : loadProgress, uploadProgress || (isDownloading ? downloadProgress : loadProgress),
shouldLoad && !fullMediaData, shouldLoad && !fullMediaData,
); );
const wasLoadDisabled = usePrevious(isLoadAllowed) === false; const wasLoadDisabled = usePrevious(isLoadAllowed) === false;

View File

@ -102,7 +102,7 @@ const Video: FC<OwnProps> = ({
const { isBuffered, bufferingHandlers } = useBuffering(!shouldAutoLoad); const { isBuffered, bufferingHandlers } = useBuffering(!shouldAutoLoad);
const { isUploading, isTransferring, transferProgress } = getMediaTransferState( const { isUploading, isTransferring, transferProgress } = getMediaTransferState(
message, message,
uploadProgress || isDownloading ? downloadProgress : loadProgress, uploadProgress || (isDownloading ? downloadProgress : loadProgress),
(shouldLoad && !isBuffered) || isDownloading, (shouldLoad && !isBuffered) || isDownloading,
); );
const wasLoadDisabled = usePrevious(isLoadAllowed) === false; const wasLoadDisabled = usePrevious(isLoadAllowed) === false;

View File

@ -258,7 +258,7 @@ export function getMessageContentFilename(message: ApiMessage) {
const baseFilename = getMessageKey(message); const baseFilename = getMessageKey(message);
if (photo) { if (photo) {
return `${baseFilename}.png`; return `${baseFilename}.jpg`;
} }
if (content.voice) { if (content.voice) {

View File

@ -84,7 +84,8 @@ export function cancelProgress(progressCallback: ApiOnProgress) {
progressCallbacks.forEach((map, url) => { progressCallbacks.forEach((map, url) => {
map.forEach((callback) => { map.forEach((callback) => {
if (callback === progressCallback) { if (callback === progressCallback) {
const parentCallback = cancellableCallbacks.get(url)!; const parentCallback = cancellableCallbacks.get(url);
if (!parentCallback) return;
cancelApiProgress(parentCallback); cancelApiProgress(parentCallback);
cancellableCallbacks.delete(url); cancellableCallbacks.delete(url);