rr- / szurubooru

Image board engine, Danbooru-style.
GNU General Public License v3.0
665 stars 175 forks source link

client: add null checks #647

Closed po5 closed 2 months ago

po5 commented 3 months ago

This fixes some crashes.

_newPostThumbnail/_newThumbnail is a special case where we should allow null for clearing on-server custom thumbnails, but it was previously crashing anyway because of a deeper rooted issue.
That's addressed in #646. In this PR the initial state just does nothing instead of crashing.

neobooru commented 3 months ago

Is there any specific reason why you chose to take x !== undefined && x !== null over something like x != undefined? I get that it is technically more correct, but does it matter in real life? Oh and thanks for all the PR's. It'll take me a while before I can get through them all, but thanks nonetheless.

po5 commented 3 months ago

Wow I did not realize null == undefined and nothing else. I guess it would work, though in a few places we do want to allow null and it's easier to tell those cases apart this way.
Will probably have another round of PRs after some are merged/closed, don't want it to be a conflict hell since some changes will depend on existing PRs.