Link previews: clean up AbortSignal types
This commit is contained in:
parent
fd579d62e4
commit
e4a632f601
4 changed files with 6 additions and 8 deletions
|
@ -2,7 +2,7 @@
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import { RequestInit, Response } from 'node-fetch';
|
import { RequestInit, Response } from 'node-fetch';
|
||||||
import { AbortSignal } from 'abort-controller';
|
import type { AbortSignal as AbortSignalForNodeFetch } from 'abort-controller';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
IMAGE_GIF,
|
IMAGE_GIF,
|
||||||
|
@ -448,7 +448,7 @@ export async function fetchLinkPreviewMetadata(
|
||||||
Accept: 'text/html,application/xhtml+xml',
|
Accept: 'text/html,application/xhtml+xml',
|
||||||
'User-Agent': USER_AGENT,
|
'User-Agent': USER_AGENT,
|
||||||
},
|
},
|
||||||
signal: abortSignal,
|
signal: abortSignal as AbortSignalForNodeFetch,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
window.log.warn(
|
window.log.warn(
|
||||||
|
@ -545,7 +545,7 @@ export async function fetchLinkPreviewImage(
|
||||||
'User-Agent': USER_AGENT,
|
'User-Agent': USER_AGENT,
|
||||||
},
|
},
|
||||||
size: MAX_IMAGE_CONTENT_LENGTH,
|
size: MAX_IMAGE_CONTENT_LENGTH,
|
||||||
signal: abortSignal,
|
signal: abortSignal as AbortSignalForNodeFetch,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
window.log.warn('fetchLinkPreviewImage: failed to fetch image; bailing');
|
window.log.warn('fetchLinkPreviewImage: failed to fetch image; bailing');
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
import { Dictionary } from 'lodash';
|
import { Dictionary } from 'lodash';
|
||||||
import PQueue from 'p-queue';
|
import PQueue from 'p-queue';
|
||||||
import { AbortSignal } from 'abort-controller';
|
|
||||||
import {
|
import {
|
||||||
PlaintextContent,
|
PlaintextContent,
|
||||||
ProtocolAddress,
|
ProtocolAddress,
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
||||||
import fetch, { Response } from 'node-fetch';
|
import fetch, { Response } from 'node-fetch';
|
||||||
import { AbortSignal } from 'abort-controller';
|
|
||||||
import ProxyAgent from 'proxy-agent';
|
import ProxyAgent from 'proxy-agent';
|
||||||
import { Agent } from 'https';
|
import { Agent } from 'https';
|
||||||
import pProps from 'p-props';
|
import pProps from 'p-props';
|
||||||
|
|
|
@ -4088,7 +4088,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
|
|
||||||
async getStickerPackPreview(
|
async getStickerPackPreview(
|
||||||
url: string,
|
url: string,
|
||||||
abortSignal: any
|
abortSignal: Readonly<AbortSignal>
|
||||||
): Promise<null | GetLinkPreviewResult> {
|
): Promise<null | GetLinkPreviewResult> {
|
||||||
const isPackDownloaded = (pack: any) =>
|
const isPackDownloaded = (pack: any) =>
|
||||||
pack && (pack.status === 'downloaded' || pack.status === 'installed');
|
pack && (pack.status === 'downloaded' || pack.status === 'installed');
|
||||||
|
@ -4164,7 +4164,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
|
|
||||||
async getGroupPreview(
|
async getGroupPreview(
|
||||||
url: string,
|
url: string,
|
||||||
abortSignal: any
|
abortSignal: Readonly<AbortSignal>
|
||||||
): Promise<null | GetLinkPreviewResult> {
|
): Promise<null | GetLinkPreviewResult> {
|
||||||
const urlObject = maybeParseUrl(url);
|
const urlObject = maybeParseUrl(url);
|
||||||
if (!urlObject) {
|
if (!urlObject) {
|
||||||
|
@ -4251,7 +4251,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
|
|
||||||
async getPreview(
|
async getPreview(
|
||||||
url: string,
|
url: string,
|
||||||
abortSignal: any
|
abortSignal: Readonly<AbortSignal>
|
||||||
): Promise<null | GetLinkPreviewResult> {
|
): Promise<null | GetLinkPreviewResult> {
|
||||||
if (window.Signal.LinkPreviews.isStickerPack(url)) {
|
if (window.Signal.LinkPreviews.isStickerPack(url)) {
|
||||||
return this.getStickerPackPreview(url, abortSignal);
|
return this.getStickerPackPreview(url, abortSignal);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue