Journaly / journaly

A foreign language journaling application.
https://journaly.com
55 stars 17 forks source link

Editing a post you wrote that's in a language you're no longer learning forces language change #509

Open Lanny opened 3 years ago

Lanny commented 3 years ago

Repro Steps

  1. Set yourself as learning German
  2. Write a post in German
  3. Remove German as a learning language
  4. Edit your post

Observe that you can not select German as the language for that post

Lanny commented 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.

meredithcat commented 3 years ago

I took a stab at fixing this one, and here's what I see needs to happen:

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.

robin-macpherson commented 3 years ago

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 🙂