Fix sticker-creator preload error

This commit is contained in:
Fedor Indutny 2022-11-30 17:44:17 -08:00 committed by GitHub
parent 38b921fad7
commit 9582f7508a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 11 deletions

View file

@ -13,7 +13,6 @@ import type { Props as DropZoneProps } from '../elements/DropZone';
import { DropZone } from '../elements/DropZone';
import { processStickerImage } from '../util/preload';
import { useI18n } from '../util/i18n';
import { ProcessStickerImageError } from '../errors';
import { MINUTE } from '../../ts/util/durations';
import * as Errors from '../../ts/types/errors';
@ -71,7 +70,7 @@ const InnerGrid = SortableContainer(
actions.removeSticker(path);
const key =
e instanceof ProcessStickerImageError
e instanceof window.ProcessStickerImageError
? e.errorMessageI18nKey
: 'StickerCreator--Toasts--errorProcessing';
actions.addToast({

View file

@ -1,8 +0,0 @@
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export class ProcessStickerImageError extends Error {
constructor(message: string, public readonly errorMessageI18nKey: string) {
super(message);
}
}

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import type { Metadata } from 'sharp';
import type { ProcessStickerImageErrorType } from '../window/phase3-sticker-functions';
declare global {
// We want to extend `window`'s properties, so we need an interface.
@ -9,6 +10,7 @@ declare global {
interface Window {
processStickerImage: ProcessStickerImageFn;
encryptAndUpload: EncryptAndUploadFn;
ProcessStickerImageError: ProcessStickerImageErrorType;
}
}

View file

@ -18,7 +18,14 @@ import { initialize as initializeWebAPI } from '../../ts/textsecure/WebAPI';
import { SignalContext } from '../../ts/windows/context';
import { getAnimatedPngDataIfExists } from '../../ts/util/getAnimatedPngDataIfExists';
import { ProcessStickerImageError } from '../errors';
class ProcessStickerImageError extends Error {
constructor(message: string, public readonly errorMessageI18nKey: string) {
super(message);
}
}
export type ProcessStickerImageErrorType = typeof ProcessStickerImageError;
window.ProcessStickerImageError = ProcessStickerImageError;
const STICKER_SIZE = 512;
const MIN_STICKER_DIMENSION = 10;