Closed jesus2099 closed 1 year ago
There is still problems with the other tools (recording open edits, relate/merge tools and Edit rec. buttons). It seems to be because of react-hydrate nightmare redrawing the last column. 😨 But beta release table last 2 columns are not stable yet, see how ratings are not clickable: https://tickets.metabrainz.org/browse/MBS-11735
Mass Merge Recordings & Set Comments for Recordings for a release have just stopped working for me. They show that they are loaded, but the button for Set Comments for Recordings no longer shows up and when I add a release into the field for remote release box, it never loads them.
It must be because of https://tickets.metabrainz.org/browse/MBS-11703 that may have introduced react-hydrate (page redraw) stuff.
The release comment script is back working. So at least that was short lived.
The release comment script was not updated in 10 month but will hopefully be fixed by its author @mwiencek soon. ;) As it's himself, bitmap, who changed release page recently in MBS-11703.
Maybe it works for you because it is running enough late (behind lots of other scripts), after react has done its deferred page redraw, or something.
As I don't understand react, I will be able to learn from his fix. I am in search of a clean stable reliable solution for these react-hydrate-deferred-page-redraws rather than my delays and other tricks.
In fact I found the react hydrate stuff in:
Sorry this causes so much trouble. :\ The main issue I see is that React will remove any elements you inject whenever it re-renders the parent. I'm not sure of the best way to handle this. MutationObserver
could work somehow, but might be slow and tedious.
I could also add some callbacks in the MBS components that userscripts could hook into and modify stuff, though this probably still requires some minor knowledge of React. It might be the most reliable option though.
Could you make a list of the different elements on the release page you need to modify/inject into?
Thanks for chiming in, @mwiencek. :)
The main issue I see is that React will remove any elements you inject whenever it re-renders the parent.
Exatcly!
I thought there were some React functions that I could call to tell React this and this had to be kept at next page redraw,
There is no such thing as a kind of react.register(myElements)
function?
I don't think MBS code should go as far as to include specific callbacks for user scripts, though. It would be too much.
If there is no clean react way, I try to make some clean new code based on setInterval
or setTimeout
functions, like I do for more and more scripts (GitHub user scripts required that, the first).
I remember I tried MutationObserver
but there were some problems I don't remember.
I only remember it was simpler and more reliable to use dumb setInterval
or setTimeout
functions.
I thought there were some React functions that I could call to tell React this and this had to be kept at next page redraw, There is no such thing as a kind of react.register(myElements) function?
Sadly no. setInterval
is probably your best bet, then -- if the elements you insert have unique IDs, getElementById
will be a very fast way to check if they were removed, allowing a smaller interval.
Thanks! 😁
Hi @mwiencek, did the div.loading-message
disappear from loading expand/collapse mediums?
It seems there is now only:
<tr><td colspan="4" style="padding: 1em;">Loading...</td></tr>
Which makes it difficult with multilingual MBS.
Before that, I used to have tr > td > div.loading-message
.
Indeed:
<tr>
<td>
<div class="loading-message">
{l('Loading...')}
</div>
</td>
</tr>
<tr>
<td>
{l('Load all tracks...')}
</td>
</tr>
Do you think this kind of stuff could be put back?
I'm pretty sure it could. I'll look into making the change.
https://github.com/metabrainz/musicbrainz-server/pull/2166 - does that look like it would work? (it'd need a small change at least since there's no longer a div
, but)
To test this out: https://musicbrainz.org/release/16caa039-aba9-45e8-9ff1-8cca8635ff52
Work amount is also broken, I now see only Tracks: https://musicbrainz.org/release/5ebe09a7-2451-47aa-91eb-9a9ce5973ef3
I will fix this by finally writing a new version that handles all kinds paginated releases (#38), like recently done for COLLECTION HIGHLIGHTER.
It will solve this issue at the same time!
This bug will soon trigger all the time, like on beta: see examples in #682.
This bug will soon trigger all the time, like on beta: see examples in #682.
Now triggering on non-beta site too.
@jesus2099 wrapping your INLINE STUFF script into a window
load
event handler seems to be a viable workaround on my end.
window.addEventListener('load', function() {
// rest of the script
});
I don't think it's truly a reliable workaround, but the React hydration errors disappeared and INLINE STUFF seems to do its job. Alternatively, @run-at document-idle
seems to solve it as well.
The reason it's not a reliable workaround is that it's also waiting for all images to finish loading. So, if the Internet Archive/CAA is having a particularly bad day, this workaround could make it so your script will only execute after the sidebar cover art is loaded, which is of course not ideal.
MutationObserver
, as recommended by bitmap previously, won't work for INLINE STUFF's hydration errors (nor will it work for my inline track recordings script, https://github.com/ROpdebee/mb-userscripts/issues/484) since there's no client-side rendering going on (unless you trigger the hydration errors, in which case React will fall back to client-side rendering).
What I think could be a decent solution would be a custom event that gets dispatched whenever hydration of a component has finished. Userscripts could then listen for that event and postpone their modifications until it arrives. Ideally the event would bubble and be dispatched on the hydrated component's root, so we can listen to it anywhere in the parent chain but still figure out which element exactly was hydrated. That also wouldn't require any tricky hooks made specifically for userscripts, and no deep React knowledge required for the userscript authors. Similar events dispatched in the client-side rendering hooks (componentDidMount
and componentDidUpdate
) would be even more amazing, then we could get notified of when userscript elements need to be reinserted instead of having to observe for that. @mwiencek does this sound feasible to you (primarily the hydration part)?
Thank you very much.
Anyway I will surely do like I did for COLLECTION HIGHLIGHTER (setInterval
: https://github.com/jesus2099/konami-command/commit/463183e3565fccb3aeffb8cac7f0647aa21e0f74).
I need to support all tracks, even those that are loaded later, with all kinds of collapsed/paginated releases.
But it might be good to put most of my scripts in document-idle
.
But at the moment I am on several other stuff, that I need more. And the workaround works for me. Maybe I will do a quick fix as you suggest, for others.
In my past https://github.com/jesus2099/konami-command/labels/react-hydrate 12 fixes "researches," I think it was not possible to wish for such post-hydrate events.
I think I always came to the conclusion that setInterval
was actually the best solution, and not so dirty, after all.
@redactedscribe @Alfge, tell me if my quick fix did the trick for you.
last update works fine now. Thanks
tell me if my quick fix did the trick for you.
Yep, works, thanks (on beta too)!
Tried the "Workaround is to make this script near or at the end of your userscript list." but doesn't help for me :-(
@Alfge did you update to version 2022.6.14
, already?
This is the version with document-idle
quick-fix, suggested by @ROpdebee, working for most people.
@mwiencek does this sound feasible to you (primarily the hydration part)?
Yes, I think custom events is a good idea.
Just updated to version 2022.6.14 and now it works for me too. Thank you!
https://musicbrainz.org/release/16caa039-aba9-45e8-9ff1-8cca8635ff52
For this release, still no comments, no ISRC, no AcoustID.
Today, that release recording comments show up (on mobile). It's very random until I fix.
I added that same old lame react hydrate workaround (delay): https://github.com/jesus2099/konami-command/commit/e54015618b4bc78899e29569ad08575bb7ff34dd?w=1
↖ #38 – NG with release with more than 10 mediums after MBS-3841
Workaround is to make this script near or at the end of your userscript list.
We cannot see recording comments since some change on beta, that will probably occur on MBS to, soon.
Spotted by @Lotheric: https://github.com/jesus2099/konami-command/issues/445#issuecomment-864572633
Fix amounts of tracks and works in 10+ medium releasesSee #38Related to