Skip to content

Commit

Permalink
Merge branch 'develop' into chore/remove-evm-gas-price-poll
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuditi authored Apr 29, 2024
2 parents b5e4f45 + 196a43e commit 7ebe148
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
19 changes: 18 additions & 1 deletion packages/desktop/components/menus/CollectibleDetailsMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import { localize } from '@core/i18n'
import { isEvmNetwork } from '@core/network'
import { IIrc27Nft, Nft, getPrimaryNftUrl, isNftLocked, isValidNftUri } from '@core/nfts'
import { updateNftInAllAccountNfts } from '@core/nfts/actions'
import { addNftsToDownloadQueue, updateNftInAllAccountNfts } from '@core/nfts/actions'
import { updatePersistedNft } from '@core/nfts/stores'
import { activeProfile, updateActiveProfile } from '@core/profile/stores'
import { Platform } from '@core/app'
export let menu: Menu | undefined = undefined
export let nft: Nft
Expand All @@ -29,6 +30,17 @@
menu?.close()
}
async function onRefreshClick(): Promise<void> {
if (nft.downloadMetadata?.filePath) {
await Platform.deleteFile(nft.downloadMetadata?.filePath)
}
updatePersistedNft(nft.id, { downloadMetadata: {} })
updateNftInAllAccountNfts(nft.id, { downloadMetadata: {}, isLoaded: false })
addNftsToDownloadQueue([nft])
menu?.close()
}
function onHideClick(): void {
updatePersistedNft(nft.id, { hidden: !nft.hidden })
updateNftInAllAccountNfts(nft.id, { hidden: !nft.hidden })
Expand Down Expand Up @@ -56,6 +68,11 @@
disabled: !isValidNftUri(nft.mediaUrl),
onClick: onOpenMediaClick,
},
{
icon: IconName.Refresh,
title: localize('views.collectibles.details.menu.refresh'),
onClick: () => void onRefreshClick(),
},
{
icon: nft.hidden ? IconName.Eye : IconName.EyeOff,
title: localize(`views.collectibles.details.menu.${nft.hidden ? 'unhide' : 'hide'}`),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
value: DownloadPermission.All,
label: localize('views.settings.downloadNftPermissions.all'),
},
// {
// value: DownloadPermission.AllExceptDenylist,
// label: localize('views.settings.downloadNftPermissions.allExceptDenylist'),
// },
{
value: DownloadPermission.AllExceptDenylist,
label: localize('views.settings.downloadNftPermissions.allExceptDenylist'),
},
{
value: DownloadPermission.AllowListOnly,
label: localize('views.settings.downloadNftPermissions.allowListOnly'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export async function checkIfNftShouldBeDownloaded(

if (!skipDownloadSettingsCheck) {
const nftSettings = getActiveProfile()?.settings?.nfts ?? {}
// TODO: Implement deny list
switch (nftSettings.downloadPermissions) {
case DownloadPermission.None:
downloadMetadata.warning = { type: DownloadWarningType.DownloadNotAllowed }
Expand All @@ -59,20 +58,31 @@ export async function checkIfNftShouldBeDownloaded(
const remoteAllowlist = get(appParameters).allowlists.urls
const allowlist = [...remoteAllowlist, ...knownGateways]
const mediaUrl = new URL(nft.mediaUrl)
const startsWithAllowedGateways =
const startsWithAllowedGateway =
mediaUrl.protocol === 'ipfs:' ||
(mediaUrl.protocol === 'https:' &&
allowlist.some((allowedUrl) => {
const url = new URL(allowedUrl)
return mediaUrl.origin === url.origin
}))
if (!startsWithAllowedGateways) {
if (!startsWithAllowedGateway) {
downloadMetadata.warning = { type: DownloadWarningType.DownloadNotAllowed }
return { shouldDownload: false, isLoaded: false, downloadMetadata }
}
break
}
case DownloadPermission.AllExceptDenylist: {
const denylist = get(appParameters).denylists.urls
const mediaUrl = new URL(nft.mediaUrl)
const startsWithDeniedGateway = denylist.some((blockedUrl) => {
return mediaUrl.origin.includes(blockedUrl)
})
if (startsWithDeniedGateway) {
downloadMetadata.warning = { type: DownloadWarningType.DownloadNotAllowed }
return { shouldDownload: false, isLoaded: false, downloadMetadata }
}
break
}
case DownloadPermission.AllExceptDenylist:
case DownloadPermission.All:
break
}
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@
"loadMedia": "Load media in wallet",
"unsetPfp": "Unset NFT profile pic",
"view": "View media in browser",
"refresh": "Refresh NFT",
"hide": "Hide NFT",
"unhide": "Unhide NFT",
"burn": "Burn NFT"
Expand Down

0 comments on commit 7ebe148

Please sign in to comment.