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