-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: editing mod tags and authors #187
fix: editing mod tags and authors #187
Conversation
@knightzac19 is attempting to deploy a commit to the satisfactorymodding Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
8ac7c05
to
53e65bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally and it fixes #162 for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of this is unnecessary, the issue is that the TagsList uses InputChip
with name="tags"
which means that on input updates the form data will be updated with the tag chip text, but the tagIDs field is updated from $data.tags
instead of tags
, so it reads the id
field of strings, and ends up being full of undefined
, failing the validation.
The only thing needed to fix the issue is
diff --git a/src/lib/components/mods/ModForm.svelte b/src/lib/components/mods/ModForm.svelte
index a62f7e0..8bd9982 100644
--- a/src/lib/components/mods/ModForm.svelte
+++ b/src/lib/components/mods/ModForm.svelte
@@ -45,15 +45,9 @@
onSubmit: (submitted: ModData) => onSubmit(trimNonSchema(submitted, modSchema))
});
- let tags = [];
- $: {
- const anyData = $data;
- if (anyData.tags) {
- tags = anyData.tags;
- delete anyData.tags;
- }
- $data.tagIDs = tags.map((tag) => tag.id);
- }
+ let tags = $data.tags ?? [];
+
+ $: $data.tagIDs = tags.map((tag) => tag.id);
// The GQL type NewMod does not have a compatibility field.
// We remove the field from the data so that the GQL request is valid
I also left a few pointers about svelte as comments on the code
Alright, I cleaned up most of the code, I was running into a lot of strange non-updating issues and undefined issues which led me down a rabbit hole. So getting rid of a lot of the extra code still let things work properly. |
I guess you're referring to the redirect back to the mod page after editing twice being blank. That one is really odd, because the API returns |
This should resolve #162 and any wonkiness that editing a mod was having due to stale data.