Skip to content

Commit b26d34f

Browse files
Fix userlist stale data (#2501)
* fix type mismatch * oops * invalidate more things
1 parent 61c92bc commit b26d34f

File tree

2 files changed

+26
-9
lines changed
  • frontends
    • api/src/hooks/learningResources
    • main/src/app/dashboard/my-lists/[id]

2 files changed

+26
-9
lines changed

frontends/api/src/hooks/learningResources/index.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,16 @@ const useLearningResourceSetUserListRelationships = () => {
9797
params: LearningResourcesApiLearningResourcesUserlistsPartialUpdateRequest,
9898
) => learningResourcesApi.learningResourcesUserlistsPartialUpdate(params),
9999
onSettled: () => {
100-
queryClient.invalidateQueries({ queryKey: userlistKeys.membershipList() })
100+
/**
101+
* We need to invalidate:
102+
* - membership check
103+
* - list of user lists (count has changed)
104+
* - userlist detail annd listing for any lists we modified
105+
*
106+
* That's a lot. Let's just invalidate root.
107+
* Additionally, the lists we've removed from the resource are not easily available.
108+
*/
109+
queryClient.invalidateQueries({ queryKey: userlistKeys.root })
101110
},
102111
})
103112
}
@@ -110,9 +119,16 @@ const useLearningResourceSetLearningPathRelationships = () => {
110119
) =>
111120
learningResourcesApi.learningResourcesLearningPathsPartialUpdate(params),
112121
onSettled: () => {
113-
queryClient.invalidateQueries({
114-
queryKey: learningPathKeys.membershipList(),
115-
})
122+
/**
123+
* We need to invalidate:
124+
* - membership check
125+
* - list of user lists (count has changed)
126+
* - userlist detail annd listing for any lists we modified
127+
*
128+
* That's a lot. Let's just invalidate root.
129+
* Additionally, the lists we've removed from the resource are not easily available.
130+
*/
131+
queryClient.invalidateQueries({ queryKey: learningPathKeys.root })
116132
},
117133
})
118134
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React from "react"
22
import { UserListDetailsContent } from "@/app-pages/DashboardPage/UserListDetailsContent"
3-
import { PageParams } from "@/app/types"
43
import invariant from "tiny-invariant"
4+
import { PageParams } from "@/app/types"
55

6-
const Page: React.FC<PageParams<object, { id: number }>> = async ({
6+
const Page: React.FC<PageParams<never, { id: string }>> = async ({
77
params,
88
}) => {
9-
const resolved = await params
10-
invariant(resolved?.id, "id is required")
11-
return <UserListDetailsContent userListId={resolved.id} />
9+
const resolved = await params!
10+
const id = Number(resolved.id)
11+
invariant(id, "id is required")
12+
return <UserListDetailsContent userListId={id} />
1213
}
1314

1415
export default Page

0 commit comments

Comments
 (0)