AprilSylph / XKit-Rewritten

🧰 The enhancement suite for Tumblr's new web interface
GNU General Public License v3.0
274 stars 44 forks source link

Quick Reblog: Don't clear popup state on error #1484

Open marcustyphoon opened 3 weeks ago

marcustyphoon commented 3 weeks ago

Description

Currently, Quick Reblog erases the popup state (actually sets lastPostID = null, the flag to erase the popup state when the popup next appears, technically) unconditionally during the reblog process. This means that API errors not only cause a failure of the user action, but result in them losing their entered tags.

This moves the clear action to after the await, so that it only occurs on success. Users can thus try again, and/or copy their tags elsewhere in order to do the reblog through the normal post form without losing their work.

I had to go git blame the conditional here because I couldn't figure out exactly what it was for.

Testing steps

(I didn't actually bother to test the delay-the-reblogPost-function-long-enough-to-move-to-another-post-while-it's-happening thing.)

marcustyphoon commented 3 weeks ago

Alternate documentation:

      const popupNotMoved = lastPostID === postID;
      if (popupNotMoved) {
        popupElement.remove();
        lastPostID = null;
      }

But, I dunno, is that clear enough?