Open Lanny opened 3 years ago
Should be a pretty straight forward fix. We compute the set of languages a user can pick 100% on the FE in the post editor, as the union of their learning and native languages. We just need to add the current language of the post to that list.
I took a stab at fixing this one, and here's what I see needs to happen:
Components: Since we can't guarantee that the post's language will be listed under the user's languages, it is no longer possible to compute the language name & level using only the language's id
. Thus, it becomes necessary to get the language name & level in the editPost
query, as well as to send the language level when creating or editing a post (because otherwise, the resolver wouldn't be able to find the "deprecated" language level).
GraphQL: As stated above, the FE now needs to be able to send the language level, as well as receive the language name. This would affect the following graphql files:
createPost
& updatePost
(mutation on post creation / edit): Need to include the language leveleditPost
(query for the edit page): Needs to include the language name & levelResolvers: The resolvers in post.ts
would no longer be responsible for setting the language level, and instead would set the language level based on the passed-in value from the client side.
The blocker I ran into is that in pages/dashboard/new-post.tsx
and pages/post/[id]/edit.tsx
, which need to set the language level in the graphql query, the currentUser
variable is a Maybe
type which is sometimes undefined. Thus, it is not always possible to retrieve the user's level for that language.
You can view my partially finished changes here, although there might still be other issues I didn't catch.
Thanks for this really helpful and detailed report @meredithcat ! 🙏🏼 I'll take a closer look over the weekend. By the way we love to encourage Draft PRs and I think this would be a perfect time for that. Let me know if you need any help with that 🙂
Repro Steps
Observe that you can not select German as the language for that post