add types for blueimp-load-image
This commit is contained in:
parent
9f14924e65
commit
f673589c56
|
@ -618,7 +618,6 @@
|
|||
onBanUser: () => this.banUser(),
|
||||
onRetrySend: () => this.retrySend(),
|
||||
onShowDetail: () => this.trigger('show-message-detail', this),
|
||||
onClickLinkPreview: url => this.trigger('navigate-to', url),
|
||||
markRead: readAt => this.markRead(readAt),
|
||||
|
||||
onShowUserDetails: pubkey =>
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
"@journeyapps/sqlcipher": "https://github.com/scottnonnenberg-signal/node-sqlcipher.git#b10f232fac62ba7f8775c9e086bb5558fe7d948b",
|
||||
"@reduxjs/toolkit": "^1.4.0",
|
||||
"@sindresorhus/is": "0.8.0",
|
||||
"@types/blueimp-load-image": "^2.23.8",
|
||||
"@types/dompurify": "^2.0.0",
|
||||
"@types/emoji-mart": "^2.11.3",
|
||||
"@types/moment": "^2.13.0",
|
||||
|
|
|
@ -379,7 +379,6 @@ const { autoOrientImage } = require('./js/modules/auto_orient_image');
|
|||
window.autoOrientImage = autoOrientImage;
|
||||
window.dataURLToBlobSync = require('blueimp-canvas-to-blob');
|
||||
window.filesize = require('filesize');
|
||||
window.loadImage = require('blueimp-load-image');
|
||||
window.getGuid = require('uuid/v4');
|
||||
window.profileImages = require('./app/profile_images');
|
||||
|
||||
|
|
|
@ -865,12 +865,6 @@ export class RegistrationTabs extends React.Component<{}, State> {
|
|||
language,
|
||||
trimName
|
||||
);
|
||||
// FIXME remove everything related to hasSeenLightModeDialog at some point in the future (27/08/2020)
|
||||
const data = {
|
||||
id: 'hasSeenLightModeDialog',
|
||||
value: true,
|
||||
};
|
||||
await createOrUpdateItem(data);
|
||||
trigger('openInbox');
|
||||
} catch (e) {
|
||||
ToastUtils.pushToastError(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { StagedAttachmentType } from '../components/session/conversation/SessionCompositionBox';
|
||||
import { SignalService } from '../protobuf';
|
||||
import { Constants } from '../session';
|
||||
|
||||
import loadImage from 'blueimp-load-image';
|
||||
export interface MaxScaleSize {
|
||||
maxSize?: number;
|
||||
maxHeight?: number;
|
||||
|
@ -40,8 +40,7 @@ export async function autoScale<T extends { contentType: string; file: any }>(
|
|||
return;
|
||||
}
|
||||
|
||||
const gifMaxSize = Constants.CONVERSATION.MAX_ATTACHMENT_FILESIZE_BYTES;
|
||||
if (file.type === 'image/gif' && file.size <= gifMaxSize) {
|
||||
if (file.type === 'image/gif' && file.size <= Constants.CONVERSATION.MAX_ATTACHMENT_FILESIZE_BYTES) {
|
||||
resolve(attachment);
|
||||
return;
|
||||
}
|
||||
|
@ -51,12 +50,11 @@ export async function autoScale<T extends { contentType: string; file: any }>(
|
|||
return;
|
||||
}
|
||||
|
||||
const canvas = window.loadImage.scale(img, {
|
||||
const canvas = (loadImage as any).scale(img, {
|
||||
canvas: true,
|
||||
maxWidth,
|
||||
maxHeight,
|
||||
});
|
||||
|
||||
let quality = 0.95;
|
||||
let i = 4;
|
||||
let blob;
|
||||
|
@ -66,22 +64,19 @@ export async function autoScale<T extends { contentType: string; file: any }>(
|
|||
canvas.toDataURL('image/jpeg', quality)
|
||||
);
|
||||
quality = (quality * maxSize) / blob.size;
|
||||
// Should we disallow the algo drop the quality too low?
|
||||
// if (quality < 0.5) {
|
||||
// quality = 0.5;
|
||||
// }
|
||||
// NOTE: During testing with a large image, we observed the
|
||||
// `quality` value being > 1. Should we clamp it to [0.5, 1.0]?
|
||||
// See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#Syntax
|
||||
|
||||
if (quality > 1) {
|
||||
quality = 1;
|
||||
quality = 0.95;
|
||||
}
|
||||
|
||||
} while (i > 0 && blob.size > maxSize);
|
||||
|
||||
|
||||
resolve({
|
||||
...attachment,
|
||||
file: blob,
|
||||
});
|
||||
|
||||
};
|
||||
img.src = url;
|
||||
});
|
||||
|
|
|
@ -20,7 +20,6 @@ export function getTimerBucket(expiration: number, length: number): string {
|
|||
if (delta > length) {
|
||||
return '60';
|
||||
}
|
||||
|
||||
const bucket = Math.round((delta / length) * 12);
|
||||
|
||||
return padStart(String(bucket * 5), 2, '0');
|
||||
|
|
|
@ -100,7 +100,6 @@ declare global {
|
|||
GroupBuffer: any;
|
||||
SwarmPolling: SwarmPolling;
|
||||
MediaRecorder: any;
|
||||
loadImage: any;
|
||||
dataURLToBlobSync: any;
|
||||
autoOrientImage: any;
|
||||
contextMenuShown: boolean;
|
||||
|
|
|
@ -367,6 +367,11 @@
|
|||
"@types/jquery" "*"
|
||||
"@types/underscore" "*"
|
||||
|
||||
"@types/blueimp-load-image@^2.23.8":
|
||||
version "2.23.8"
|
||||
resolved "https://registry.yarnpkg.com/@types/blueimp-load-image/-/blueimp-load-image-2.23.8.tgz#0d10f12bf57f050aceac06dcc76390ae759c979a"
|
||||
integrity sha512-dy98N4odO9L1zgo2a6yVHRRYUeYRJfl0hg3dcapyxqNq5KF8Zgz5lFWgDMOsMC06VAs0mnVKDRJE4+U/A5Km3A==
|
||||
|
||||
"@types/bytebuffer@^5.0.41":
|
||||
version "5.0.41"
|
||||
resolved "https://registry.yarnpkg.com/@types/bytebuffer/-/bytebuffer-5.0.41.tgz#6850dba4d4cd2846596b4842874d5bfc01cd3db1"
|
||||
|
|
Loading…
Reference in New Issue