mirror of
https://github.com/danog/telegram-tt.git
synced 2025-01-22 05:11:55 +01:00
Composer: Fix several pasting bugs on Firefox (#1478)
This commit is contained in:
parent
92ff13dd1e
commit
54d6b581da
@ -29,12 +29,12 @@ export default (
|
||||
const file = media && media.getAsFile();
|
||||
const pastedText = e.clipboardData.getData('text').substring(0, MAX_MESSAGE_LENGTH);
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (!file && !pastedText) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (file && !editedMessage) {
|
||||
const attachment = await buildAttachment(file.name, file, true);
|
||||
setAttachments((attachments) => [
|
||||
|
@ -44,6 +44,9 @@ async function scale(
|
||||
try {
|
||||
const bitmap = await window.createImageBitmap(img,
|
||||
{ resizeWidth: width, resizeHeight: height, resizeQuality: 'high' });
|
||||
if (bitmap.height !== height || bitmap.width !== width) {
|
||||
throw new Error('Image bitmap resize not supported!'); // FF93 added support for options, but not resize
|
||||
}
|
||||
return await new Promise((res) => {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = bitmap.width;
|
||||
@ -58,10 +61,10 @@ async function scale(
|
||||
});
|
||||
} catch (e) {
|
||||
// Fallback. Firefox below 93 does not recognize `createImageBitmap` with 2 parameters
|
||||
return steppedScale(img, width, height, 0.5, outputType);
|
||||
return steppedScale(img, width, height, undefined, outputType);
|
||||
}
|
||||
} else {
|
||||
return steppedScale(img, width, height, 0.5, outputType);
|
||||
return steppedScale(img, width, height, undefined, outputType);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user