mirror of
https://github.com/modrinth/code.git
synced 2026-08-26 01:26:23 +00:00
perf: further reduce memory (#7015)
* feat: server source maps * perf: strip unused fields from search results * perf: reduce game version memory usage
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import type { Labrinth } from '@modrinth/api-client'
|
||||
|
||||
import { setGameVersions } from '~/composables/generated'
|
||||
|
||||
export default defineNuxtPlugin((nuxtApp) => {
|
||||
// Deferred until after hydration: the server renders with the build-time game versions, so
|
||||
// swapping them in during setup would make the first client render disagree with the markup.
|
||||
nuxtApp.hook('app:suspense:resolve', async () => {
|
||||
try {
|
||||
const gameVersions = await $fetch<Labrinth.Tags.v2.GameVersion[]>('/api/tags/game-versions')
|
||||
|
||||
if (gameVersions && gameVersions.length > 0) {
|
||||
setGameVersions(gameVersions)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Game Version Updater] Failed to fetch:', error)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -1,17 +0,0 @@
|
||||
import type { Labrinth } from '@modrinth/api-client'
|
||||
|
||||
export default defineNuxtPlugin(async () => {
|
||||
try {
|
||||
const gameVersions = await $fetch<Labrinth.Tags.v2.GameVersion[]>('/api/tags/game-versions')
|
||||
|
||||
if (gameVersions && gameVersions.length > 0) {
|
||||
const state = useState<{ gameVersions: Labrinth.Tags.v2.GameVersion[] }>('generatedState')
|
||||
|
||||
if (state.value) {
|
||||
state.value.gameVersions = gameVersions
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Game Version Updater] Failed to fetch:', error)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user