Introduce an image sizes cache to improve feed layouts (close #213) (#335)

* Introduce an image sizes cache to improve feed layouts (close #213)

* Clear out resolved promises from the image cache
This commit is contained in:
Paul Frazee 2023-03-21 12:59:10 -05:00 committed by GitHub
parent c1d454b7cf
commit 858d4c8c88
7 changed files with 92 additions and 30 deletions

View file

@ -5,6 +5,11 @@ import RNFS from 'react-native-fs'
import uuid from 'react-native-uuid'
import * as Toast from 'view/com/util/Toast'
export interface Dim {
width: number
height: number
}
export interface DownloadAndResizeOpts {
uri: string
width: number
@ -119,10 +124,6 @@ export async function compressIfNeeded(
return finalImg
}
export interface Dim {
width: number
height: number
}
export function scaleDownDimensions(dim: Dim, max: Dim): Dim {
if (dim.width < max.width && dim.height < max.height) {
return dim