fix: add compatibility for legacy formats (#514)
This commit is contained in:
parent
6d75d56a0f
commit
32e82e69ba
|
|
@ -77,7 +77,7 @@ export default function SiteSettingsGeneralPage() {
|
|||
!form.getValues("banner") &&
|
||||
form.setValue(
|
||||
"banner",
|
||||
site.data?.metadata?.content?.banners?.[0]
|
||||
site.data?.metadata?.content?.banners?.[0]?.address
|
||||
? {
|
||||
address: toIPFS(
|
||||
site.data?.metadata?.content?.banners?.[0].address || "",
|
||||
|
|
|
|||
|
|
@ -46,8 +46,27 @@ export const SiteFooter: React.FC<{
|
|||
{site?.metadata?.content?.connected_accounts && (
|
||||
<div className="sm:-mr-5 sm:block inline-block align-middle mr-4">
|
||||
{site?.metadata?.content?.connected_accounts.map(
|
||||
(account, index) => {
|
||||
const match = account.match(/:\/\/account:(.*)@(.*)/)
|
||||
(
|
||||
account:
|
||||
| string
|
||||
| { uri: string }
|
||||
| { identity: string; platform: string }
|
||||
| any, // Otherwise type check will alarm
|
||||
index,
|
||||
) => {
|
||||
let match: RegExpMatchArray | null = null
|
||||
switch (typeof account) {
|
||||
case "string":
|
||||
match = account.match(/:\/\/account:(.*)@(.*)/)
|
||||
break
|
||||
case "object":
|
||||
if (account.uri) {
|
||||
match = account.uri.match(/:\/\/account:(.*)@(.*)/)
|
||||
} else if (account.identity && account.platform) {
|
||||
match = ["", account.identity, account.platform]
|
||||
}
|
||||
break
|
||||
}
|
||||
if (match) {
|
||||
return (
|
||||
<Platform
|
||||
|
|
|
|||
|
|
@ -124,10 +124,25 @@ export const expandCrossbellCharacter = (site: CharacterEntity) => {
|
|||
)
|
||||
}
|
||||
if (expandedCharacter.metadata.content.banners) {
|
||||
expandedCharacter.metadata.content.banners.map((banner) => {
|
||||
banner.address = toGateway(banner.address)
|
||||
return banner
|
||||
})
|
||||
expandedCharacter.metadata.content.banners.map(
|
||||
(banner: { address: string; mime_type: string } | string) => {
|
||||
let expandedBanner
|
||||
switch (typeof banner) {
|
||||
case "string":
|
||||
expandedBanner = {
|
||||
address: toGateway(banner),
|
||||
}
|
||||
break
|
||||
case "object":
|
||||
expandedBanner = {
|
||||
...banner,
|
||||
address: toGateway(banner.address),
|
||||
}
|
||||
break
|
||||
}
|
||||
return expandedBanner
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
return expandedCharacter
|
||||
|
|
|
|||
Loading…
Reference in New Issue