Don't preload too much content
Remove loading teams from getServerSideProps
This commit is contained in:
parent
54cecdc9df
commit
7a6105b19f
4 changed files with 11 additions and 30 deletions
|
|
@ -13,14 +13,12 @@ import useDidMountEffect from '~hooks/useDidMountEffect'
|
|||
// Utils
|
||||
import fetchLatestVersion from '~utils/fetchLatestVersion'
|
||||
import { appState } from '~utils/appState'
|
||||
import { convertAdvancedFilters } from '~utils/convertAdvancedFilters'
|
||||
import { CollectionPage } from '~utils/enums'
|
||||
import { permissiveFilterset } from '~utils/defaultFilters'
|
||||
import { setHeaders } from '~utils/userToken'
|
||||
import {
|
||||
fetchRaidGroupsAndFilters,
|
||||
fetchUserProfile,
|
||||
parseAdvancedFilters,
|
||||
} from '~utils/serverSideUtils'
|
||||
|
||||
// Types
|
||||
|
|
@ -230,16 +228,11 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
|
|||
|
||||
// Perform a request only if we received a username
|
||||
if (query.username) {
|
||||
const { user, teams, pagination } = await fetchUserProfile(
|
||||
query.username,
|
||||
filters
|
||||
)
|
||||
const { user } = await fetchUserProfile(query.username, {})
|
||||
|
||||
context = {
|
||||
user: user,
|
||||
teams: teams,
|
||||
raidGroups: raidGroups,
|
||||
pagination: pagination,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,15 +13,10 @@ import useDidMountEffect from '~hooks/useDidMountEffect'
|
|||
// Utils
|
||||
import fetchLatestVersion from '~utils/fetchLatestVersion'
|
||||
import { appState } from '~utils/appState'
|
||||
import { convertAdvancedFilters } from '~utils/convertAdvancedFilters'
|
||||
import { CollectionPage } from '~utils/enums'
|
||||
import { permissiveFilterset } from '~utils/defaultFilters'
|
||||
import { setHeaders } from '~utils/userToken'
|
||||
import {
|
||||
fetchRaidGroupsAndFilters,
|
||||
fetchSaved,
|
||||
parseAdvancedFilters,
|
||||
} from '~utils/serverSideUtils'
|
||||
import { fetchRaidGroups } from '~utils/serverSideUtils'
|
||||
|
||||
// Types
|
||||
import type { AxiosError } from 'axios'
|
||||
|
|
@ -222,12 +217,11 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
|
|||
|
||||
try {
|
||||
// We don't pre-load advanced filters here
|
||||
const { raidGroups, filters } = await fetchRaidGroupsAndFilters(query)
|
||||
const { teams, pagination } = await fetchSaved(filters)
|
||||
const raidGroups= await fetchRaidGroups()
|
||||
|
||||
return {
|
||||
props: {
|
||||
context: { teams, raidGroups, pagination },
|
||||
context: { raidGroups },
|
||||
version,
|
||||
error: false,
|
||||
...(await serverSideTranslations(locale, ['common'])),
|
||||
|
|
|
|||
|
|
@ -14,14 +14,9 @@ import useDidMountEffect from '~hooks/useDidMountEffect'
|
|||
// Utils
|
||||
import fetchLatestVersion from '~utils/fetchLatestVersion'
|
||||
import { appState } from '~utils/appState'
|
||||
import { convertAdvancedFilters } from '~utils/convertAdvancedFilters'
|
||||
import { defaultFilterset } from '~utils/defaultFilters'
|
||||
import { setHeaders } from '~utils/userToken'
|
||||
import {
|
||||
fetchParties,
|
||||
fetchRaidGroupsAndFilters,
|
||||
parseAdvancedFilters,
|
||||
} from '~utils/serverSideUtils'
|
||||
import { fetchRaidGroups } from '~utils/serverSideUtils'
|
||||
|
||||
// Types
|
||||
import type { NextApiRequest, NextApiResponse } from 'next'
|
||||
|
|
@ -205,16 +200,11 @@ export const getServerSideProps = async ({ req, res, locale, query }: { req: Nex
|
|||
const version = await fetchLatestVersion()
|
||||
|
||||
try {
|
||||
const advancedFilters = parseAdvancedFilters(req, res)
|
||||
const convertedFilters = advancedFilters
|
||||
? convertAdvancedFilters(advancedFilters)
|
||||
: undefined
|
||||
const { raidGroups, filters } = await fetchRaidGroupsAndFilters(query)
|
||||
const { teams, pagination } = await fetchParties(filters, convertedFilters)
|
||||
const raidGroups = await fetchRaidGroups()
|
||||
|
||||
return {
|
||||
props: {
|
||||
context: { teams, raidGroups, pagination },
|
||||
context: { raidGroups },
|
||||
version,
|
||||
error: false,
|
||||
...(await serverSideTranslations(locale, ['common'])),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ export async function fetchRaidGroupsAndFilters(query: {
|
|||
return { raidGroups, filters }
|
||||
}
|
||||
|
||||
export async function fetchRaidGroups() {
|
||||
return await api.raidGroups().then((response) => response.data)
|
||||
}
|
||||
|
||||
// Fetch initial set of parties
|
||||
export async function fetchParties(
|
||||
filters: FilterObject,
|
||||
|
|
|
|||
Loading…
Reference in a new issue