Skip to content

Commit

Permalink
Merge branch 'main' into parallel-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
petersopko authored Sep 27, 2022
2 parents 76641bb + 01126c5 commit c982015
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
9 changes: 8 additions & 1 deletion components/rmrk/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const getSanitizer = (
ipfsProvider?: ProviderKeyType,
arProvider?: ArweaveProviders
): SanitizerFunc => {
if (isIpfsUrl(url)) {
if (url && (isIpfsUrl(url) || url.includes('https://gateway.pinata.cloud'))) {
return (link) => sanitizeIpfsUrl(link, ipfsProvider)
}

Expand All @@ -176,6 +176,13 @@ export const sanitizeIpfsUrl = (
ipfsUrl: string,
provider?: ProviderKeyType
): string => {
if (ipfsUrl.includes('https://gateway.pinata.cloud')) {
return ipfsUrl.replace(
'https://gateway.pinata.cloud/',
resolveProvider(provider)
)
}

if (isIpfsCid(ipfsUrl)) {
return sanitizeIpfsCid(ipfsUrl, provider)
}
Expand Down
2 changes: 1 addition & 1 deletion components/shared/view/BasicImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const placeholder = computed(() => {
})
function onImageError(ev: Event, src: string) {
$consola.log('[BasicImage] to load:', src, ev)
$consola.error('[BasicImage] to load:', src, ev)
}
</script>

Expand Down
9 changes: 5 additions & 4 deletions utils/cachingStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const cacheOrFetchMetadata = async <T>(

try {
const meta = await fetchMetadata<T>({ metadata })
update(metadata, () => meta) // DEV: think how does it behave in
metadata && update(metadata, () => meta) // DEV: think how does it behave in
return meta
} catch (e) {
console.warn('[ERR] unable to get metadata', e)
Expand All @@ -64,17 +64,18 @@ export const getSingleCloudflareImage = async (
}

export const processSingleMetadata = async <T>(metadata: string): P<T> => {
const meta = await get(metadata)
const meta = metadata ? await get(metadata) : undefined
return cacheOrFetchMetadata(meta, metadata)
}

export const processMetadata = async <T>(
metadataList: string[],
cb?: (meta: T, index: number) => void
): P<void> => {
const storedMetadata = await getMany<T>(metadataList)
const metadata = metadataList.map((meta) => meta || '')
const storedMetadata = await getMany<T>(metadata)
storedMetadata.forEach(async (m, i) => {
const meta = await cacheOrFetchMetadata(m, metadataList[i])
const meta = await cacheOrFetchMetadata(m, metadata[i])
if (cb) {
cb(meta, i)
}
Expand Down

0 comments on commit c982015

Please sign in to comment.