From 543ac86d03b5f1c9775bf4d54a3606e262f66bf4 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sun, 21 Mar 2021 23:06:53 +0100 Subject: [PATCH] Fixed #43 #73 #58 --- src/@types/react-navigation.d.ts | 1 - src/api/instance.ts | 11 +- src/components/GracefullyImage.tsx | 6 +- src/components/Parse/HTML.tsx | 2 +- src/components/Timeline/Shared/Attachment.tsx | 1 - src/components/Timeline/Shared/Card.tsx | 4 +- src/components/openLink.ts | 120 +++++++++++++++++- src/screens/ImageViewer/@types/index.ts | 9 -- src/screens/ImageViewer/Root.tsx | 13 +- .../components/ImageItem.android.tsx | 8 +- .../ImageViewer/components/ImageItem.ios.tsx | 8 +- .../ImageViewer/hooks/usePanResponder.ts | 2 +- src/screens/ImagesViewer.tsx | 26 ++-- src/utils/queryHooks/search.ts | 9 +- 14 files changed, 174 insertions(+), 46 deletions(-) diff --git a/src/@types/react-navigation.d.ts b/src/@types/react-navigation.d.ts index 58d7b2f1..33834f60 100644 --- a/src/@types/react-navigation.d.ts +++ b/src/@types/react-navigation.d.ts @@ -60,7 +60,6 @@ declare namespace Nav { url: Mastodon.AttachmentImage['url'] width?: number height?: number - preview_url: Mastodon.AttachmentImage['preview_url'] remote_url?: Mastodon.AttachmentImage['remote_url'] }[] id: Mastodon.Attachment['id'] diff --git a/src/api/instance.ts b/src/api/instance.ts index 5bfd48c8..d64457c5 100644 --- a/src/api/instance.ts +++ b/src/api/instance.ts @@ -1,5 +1,5 @@ import { RootState } from '@root/store' -import axios from 'axios' +import axios, { AxiosRequestConfig } from 'axios' import chalk from 'chalk' import li from 'li' @@ -14,7 +14,10 @@ export type Params = { } headers?: { [key: string]: string } body?: FormData - onUploadProgress?: (progressEvent: any) => void + extras?: Omit< + AxiosRequestConfig, + 'method' | 'url' | 'params' | 'headers' | 'data' + > } const apiInstance = async ({ @@ -24,7 +27,7 @@ const apiInstance = async ({ params, headers, body, - onUploadProgress + extras }: Params): Promise<{ body: T; links: { prev?: string; next?: string } }> => { const { store } = require('@root/store') const state = store.getState() as RootState @@ -70,7 +73,7 @@ const apiInstance = async ({ }) }, ...(body && { data: body }), - ...(onUploadProgress && { onUploadProgress: onUploadProgress }) + ...extras }) .then(response => { let prev diff --git a/src/components/GracefullyImage.tsx b/src/components/GracefullyImage.tsx index f7da33b2..04ad5270 100644 --- a/src/components/GracefullyImage.tsx +++ b/src/components/GracefullyImage.tsx @@ -102,7 +102,11 @@ const GracefullyImage = React.memo( return (