This commit is contained in:
2026-02-02 18:39:43 -07:00
parent c052aa95b5
commit e5b9f1ef56
2 changed files with 45 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import axios from 'axios'
import { BackButton } from '@/app/components/BackButton' import { BackButton } from '@/app/components/BackButton'
import { ReloadButton } from '@/app/components/ReloadButton' import { ReloadButton } from '@/app/components/ReloadButton'
import { UploadButton } from '@/app/components/UploadButton' import { UploadButton } from '@/app/components/UploadButton'
import { CustomIconEntry } from '../chatroom/page'
interface MarketplaceIcon { interface MarketplaceIcon {
username: string username: string
@@ -19,6 +20,7 @@ interface MarketplaceIcon {
export default function BerryDashIconMarketplace () { export default function BerryDashIconMarketplace () {
const [response, setResponse] = useState<MarketplaceIcon[] | null | -1>(null) const [response, setResponse] = useState<MarketplaceIcon[] | null | -1>(null)
const [customIconCache, setCustomIconCache] = useState<CustomIconEntry[]>([])
async function Refresh () { async function Refresh () {
try { try {
@@ -34,6 +36,42 @@ export default function BerryDashIconMarketplace () {
Refresh() Refresh()
}, []) }, [])
useEffect(() => {
if (response == null || response == -1) return
const all = customIconCache.map(icon => icon.id)
const allFromMessages = Array.from(
new Set(response.filter(icon => icon.id != null).map(icon => icon.id))
)
const notInAllIds = allFromMessages
.filter(id => !all.includes(id))
.map(id => `"${id}"`)
.join(',')
if (notInAllIds.length != 0) {
;(async () => {
const result = await axios.get(
`/api/berrydash/icon-marketplace/icon?ids=[${notInAllIds}]`
)
if (result.data.success) {
const add: CustomIconEntry[] = []
for (const item of result.data.data) {
add.push({
data: item.data,
id: item.id
})
}
setCustomIconCache(prev => [
...prev,
...result.data.data.map((item: CustomIconEntry) => ({
data: item.data,
id: item.id
}))
])
}
})()
}
}, [response])
return ( return (
<div className='box text-center'> <div className='box text-center'>
<BackButton href='/game/berry-dash' /> <BackButton href='/game/berry-dash' />
@@ -56,7 +94,12 @@ export default function BerryDashIconMarketplace () {
<div className='sub-box2'> <div className='sub-box2'>
<div className='bg-(--col8) rounded-md w-fit h-fit p-2 mx-auto'> <div className='bg-(--col8) rounded-md w-fit h-fit p-2 mx-auto'>
<img <img
src={`data:image/png;base64,${icon.data}`} src={
customIconCache.find(i => i.id === icon.id)
? 'data:image/png;base64,' +
customIconCache.find(i => i.id === icon.id)?.data
: 'https://games-r2.lncvrt.xyz/game-assets/berrydash/other/loading.png'
}
width={96} width={96}
height={96} height={96}
draggable={false} draggable={false}

View File

@@ -114,7 +114,7 @@ export default function BerryDashGameInfo () {
View & interact with the Chatroom! View & interact with the Chatroom!
</Link> </Link>
<Link href='/game/berry-dash/leaderboards' draggable={false}> <Link href='/game/berry-dash/leaderboards' draggable={false}>
View the Leaderboards View the Leaderboards!
</Link> </Link>
</div> </div>
<p className='text-2xl my-1'>Downloads</p> <p className='text-2xl my-1'>Downloads</p>