Link previews: clean up AbortSignal types

This commit is contained in:
Evan Hahn 2021-06-08 15:55:37 -05:00 committed by GitHub
parent fd579d62e4
commit e4a632f601
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 8 deletions

View file

@ -2,7 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import { RequestInit, Response } from 'node-fetch';
import { AbortSignal } from 'abort-controller';
import type { AbortSignal as AbortSignalForNodeFetch } from 'abort-controller';
import {
IMAGE_GIF,
@ -448,7 +448,7 @@ export async function fetchLinkPreviewMetadata(
Accept: 'text/html,application/xhtml+xml',
'User-Agent': USER_AGENT,
},
signal: abortSignal,
signal: abortSignal as AbortSignalForNodeFetch,
});
} catch (err) {
window.log.warn(
@ -545,7 +545,7 @@ export async function fetchLinkPreviewImage(
'User-Agent': USER_AGENT,
},
size: MAX_IMAGE_CONTENT_LENGTH,
signal: abortSignal,
signal: abortSignal as AbortSignalForNodeFetch,
});
} catch (err) {
window.log.warn('fetchLinkPreviewImage: failed to fetch image; bailing');

View file

@ -10,7 +10,6 @@
import { Dictionary } from 'lodash';
import PQueue from 'p-queue';
import { AbortSignal } from 'abort-controller';
import {
PlaintextContent,
ProtocolAddress,

View file

@ -10,7 +10,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import fetch, { Response } from 'node-fetch';
import { AbortSignal } from 'abort-controller';
import ProxyAgent from 'proxy-agent';
import { Agent } from 'https';
import pProps from 'p-props';

View file

@ -4088,7 +4088,7 @@ Whisper.ConversationView = Whisper.View.extend({
async getStickerPackPreview(
url: string,
abortSignal: any
abortSignal: Readonly<AbortSignal>
): Promise<null | GetLinkPreviewResult> {
const isPackDownloaded = (pack: any) =>
pack && (pack.status === 'downloaded' || pack.status === 'installed');
@ -4164,7 +4164,7 @@ Whisper.ConversationView = Whisper.View.extend({
async getGroupPreview(
url: string,
abortSignal: any
abortSignal: Readonly<AbortSignal>
): Promise<null | GetLinkPreviewResult> {
const urlObject = maybeParseUrl(url);
if (!urlObject) {
@ -4251,7 +4251,7 @@ Whisper.ConversationView = Whisper.View.extend({
async getPreview(
url: string,
abortSignal: any
abortSignal: Readonly<AbortSignal>
): Promise<null | GetLinkPreviewResult> {
if (window.Signal.LinkPreviews.isStickerPack(url)) {
return this.getStickerPackPreview(url, abortSignal);