fix: cache revalidation logic for language switcher
This commit is contained in:
@@ -39,6 +39,7 @@ import {
|
||||
validateHeaderConfigSchema,
|
||||
validateLanguageSwitcherData,
|
||||
} from "./output"
|
||||
import { languageSwitcherAffix } from "./utils"
|
||||
|
||||
import {
|
||||
LanguageSwitcherData,
|
||||
@@ -144,6 +145,18 @@ export const configQueryRouter = router({
|
||||
languageSwitcher: contentstackProcedure.query(async ({ ctx }) => {
|
||||
const variables = { uid: ctx.uid, locale: ctx.lang }
|
||||
let urls: LanguageSwitcherData
|
||||
|
||||
const tagsDaDeEn = [
|
||||
generateTag(Lang.da, ctx.uid, languageSwitcherAffix),
|
||||
generateTag(Lang.de, ctx.uid, languageSwitcherAffix),
|
||||
generateTag(Lang.en, ctx.uid, languageSwitcherAffix),
|
||||
]
|
||||
const tagsFiNoSv = [
|
||||
generateTag(Lang.fi, ctx.uid, languageSwitcherAffix),
|
||||
generateTag(Lang.no, ctx.uid, languageSwitcherAffix),
|
||||
generateTag(Lang.sv, ctx.uid, languageSwitcherAffix),
|
||||
]
|
||||
|
||||
switch (ctx.contentType) {
|
||||
case PageTypeEnum.accountPage:
|
||||
const accountPageRes = await batchRequest<LanguageSwitcherQueryDataRaw>(
|
||||
@@ -151,10 +164,12 @@ export const configQueryRouter = router({
|
||||
{
|
||||
document: GetDaDeEnUrlsAccountPage,
|
||||
variables,
|
||||
tags: tagsDaDeEn,
|
||||
},
|
||||
{
|
||||
document: GetFiNoSvUrlsAccountPage,
|
||||
variables,
|
||||
tags: tagsFiNoSv,
|
||||
},
|
||||
]
|
||||
)
|
||||
@@ -184,10 +199,12 @@ export const configQueryRouter = router({
|
||||
{
|
||||
document: GetDaDeEnUrlsLoyaltyPage,
|
||||
variables,
|
||||
tags: tagsDaDeEn,
|
||||
},
|
||||
{
|
||||
document: GetFiNoSvUrlsLoyaltyPage,
|
||||
variables,
|
||||
tags: tagsFiNoSv,
|
||||
},
|
||||
]
|
||||
)
|
||||
@@ -222,10 +239,12 @@ export const configQueryRouter = router({
|
||||
{
|
||||
document: GetDaDeEnUrlsCurrentBlocksPage,
|
||||
variables,
|
||||
tags: tagsDaDeEn,
|
||||
},
|
||||
{
|
||||
document: GetFiNoSvUrlsCurrentBlocksPage,
|
||||
variables,
|
||||
tags: tagsFiNoSv,
|
||||
},
|
||||
])
|
||||
|
||||
|
||||
1
server/routers/contentstack/config/utils.ts
Normal file
1
server/routers/contentstack/config/utils.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const languageSwitcherAffix = "languageSwitcher"
|
||||
Reference in New Issue
Block a user