-
Notifications
You must be signed in to change notification settings - Fork 187
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
Split out editing venues from editing schedule #10028
base: main
Are you sure you want to change the base?
Split out editing venues from editing schedule #10028
Conversation
both point to the same react component
not actually doing anything, as far as I can tell
since it doesn't exist anymore
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.
I tried and nothing on the venues page nor on the schedule page saves - when I refresh, the original (old) data reappears.
I can successfully edit events.
app/webpacker/lib/utils/wcif.js
Outdated
|
||
save(url, wcifData, onSuccess, options, onError); | ||
}, | ||
[save], | ||
[save, patchOpts], |
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.
You're passing patchOpts
as an object (useSaveWcifAction({ skipSchedule: true })
) which means this will be a fresh object (reference) each render, so this saveWcif
will re-compute every time, negating the use of useCallback
. If any code is relying on saveWcif
never re-computing (i.e. using saveWcif
in a dependency array somewhere), then this will break that code.
This can be avoided by defining const wcifSaveOptions = { skipSchedule: true }
outside the component. But it doesn't prevent anyone in the future from passing in an object 'incorrectly.'
(I'm not sure if the default value {}
is a fresh object each time?)
Making the options a parameter to save
, instead of the hook itself, might work.
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.
Fixed! Should now be less recompute-heavy. And this incidentally also fixes the error with the backend not saving, because the PATCH request was accidentally passing undefined
in the URL under certain circumstances.
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.
Everything looks good to me, and works well as far as I can tell.
I wonder if specifying what should be saved, rather than what should not be saved, might be better though? In the past I have been editing groups in delegate dashboard, and also editing the schedule on the site, and overwritten myself, for example.
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.
No wait, adding rooms might still cause conflicts when editing in different browser tabs. I will investigate more tomorrow. But your changes certainly haven't made anything worse.
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.
Things that can go wrong with 2 tabs open for venues/schedule respectively:
- Delete a venue/room & save, then edit the schedule in that room & save -> 'invalid json' error
- Copy an existing room (in venue editor) & save, then edit anything in the schedule & save -> new copied room is gone
- Maybe other scenarios
Simple things like editing the fields of venues/rooms while editing the schedule seem to work fine, as far as I can tell.
The styling is a bit off with the "Venues + Add a venue" and the text at the top of each tab being a bit close to the content below (formerly there was an accordion).
Now each folder has an
index
and a (single) component subfolder with anotherindex
, so it might be worth bringing those subfolder contents up and having a singleindex
(maybe as a follow-up PR?).There's some minor duplication now, since everything was duplicated then trimmed away, mostly in the 2 top-level
index
files.I removed a scss file because it didn't appear to be doing anything, but I'm not 100% confident in this.