Fixes
This commit is contained in:
@@ -5,6 +5,7 @@ import axios from 'axios'
|
||||
import { BackButton } from '@/app/components/BackButton'
|
||||
import { ReloadButton } from '@/app/components/ReloadButton'
|
||||
import { UploadButton } from '@/app/components/UploadButton'
|
||||
import { CustomIconEntry } from '../chatroom/page'
|
||||
|
||||
interface MarketplaceIcon {
|
||||
username: string
|
||||
@@ -19,6 +20,7 @@ interface MarketplaceIcon {
|
||||
|
||||
export default function BerryDashIconMarketplace () {
|
||||
const [response, setResponse] = useState<MarketplaceIcon[] | null | -1>(null)
|
||||
const [customIconCache, setCustomIconCache] = useState<CustomIconEntry[]>([])
|
||||
|
||||
async function Refresh () {
|
||||
try {
|
||||
@@ -34,6 +36,42 @@ export default function BerryDashIconMarketplace () {
|
||||
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 (
|
||||
<div className='box text-center'>
|
||||
<BackButton href='/game/berry-dash' />
|
||||
@@ -56,7 +94,12 @@ export default function BerryDashIconMarketplace () {
|
||||
<div className='sub-box2'>
|
||||
<div className='bg-(--col8) rounded-md w-fit h-fit p-2 mx-auto'>
|
||||
<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}
|
||||
height={96}
|
||||
draggable={false}
|
||||
|
||||
@@ -114,7 +114,7 @@ export default function BerryDashGameInfo () {
|
||||
View & interact with the Chatroom!
|
||||
</Link>
|
||||
<Link href='/game/berry-dash/leaderboards' draggable={false}>
|
||||
View the Leaderboards
|
||||
View the Leaderboards!
|
||||
</Link>
|
||||
</div>
|
||||
<p className='text-2xl my-1'>Downloads</p>
|
||||
|
||||
Reference in New Issue
Block a user