There were a few instances where in the editor ended up failing to "save", but the generator saving process still succeeded and is still recorded in the revisions.
I was editing my generator hub page that day and saved it by clicking on the save button and then it errors after a classic 20 seconds...
I decided to check the DevTools network and it shows all the details behind that saving process, and things look suspicious, until the revisions told me wrong.
This isn't a full answer, but one thing which should help a bit here is to use this:
let generatorNameArray = ["generator-name", "another-generator-name"];
let generatorDataArray = await fetch("https://perchance.org/api/getGeneratorStats?names="+generatorNameArray.join(",")).then(r => r.json());
instead of making lots of separate requests (currently 138 requests for stats on power-generator-manager according to DevTools). The reason this should help is because (IIRC), the save process waits for the full page to reload in case of (currently undocumented) dynamic $meta info, and I think lots of requests may slow it down a bit.
I've added some code to potentially help speed things up, and ensure that "saving..." immediately shows when you hit ctrl+s, and prevents other save processes from starting at the same time, which I think could cause a traffic jam of save requests, or something.
Either way, the current code I have for saving isn't super ideal - it's definitely slower than it should be, especially for lots of imports, but the above two things should hopefully help a little bit until I get around to speeding it up.
Thanks for the code snippet, I'm actually working on another Generator Manager update and have started to implement this into the total view calculation function (totalStats()). Though I'm not sure if this could be used for the view counters in the generator items.
For now, the code for the function looks a bit like this:
Code for a future Generator Manager update
async function totalStats() {
// We already had the URLs from all the generators on the page and compiled them through the all_link variable
let tot = await fetch("https://perchance.org/api/getGeneratorStats?names="+all_link.joinItems(",")).then(r => r.json());
let ftot = 0;
for (let v of tot.data.map(x => x.views)) {
ftot += v; // Add up to make the total views
}
// We need to set two total view counters in the top banner and on the Statistics section in the About page
for (let el of document.querySelectorAll(".tstxt")) {
el.innerHTML = enableRawStats ? ftot.toLocaleString() : formatNumber(ftot);
}
// Set the total views counter in the top banner
}; totalStats();
The totalStats() function is now an async function and sets the total view counter on the top banner right away instead of just returning the value of it, so this time I no longer need a timer that does this job consecutively anymore. And this greatly reduced the delay for the total views counter to appear.
I’ve added some code to potentially help speed things up, and ensure that “saving…” immediately shows when you hit ctrl+s,
Is this implementation still triggers the "error" whenever the save fails after 20 seconds, and instead of staying on the "saving..." state indefinitely? I see that nowadays it still occasionally ends up on the "error" state.
Thanks so much @perchance, you're showing up! I might as well implement this in a future post-announcement update of my generator hub page after the Milestone Announcement has been launched to the ground in days.
@perchance My generator hub page is loaded with a lot of imports and due to the "save-after-reload" behavior, it took some time to "reload" and save unlike my other generators that use less imports (such as the Popularity Achievement Generator: https://perchance.org/popularity-achievement-generator).
But sometimes the reload can took a very long time (like 30 mins), so I think I'll just have to see the network tab to make absolute sure that the generator is actually saved 😆 (if anything seems to be wrong once again)
Update: I just noticed another change on the saving system. Instead of the "save-after-reload," it now sort of combines original save behavior and the last one, meaning that the save button will now say "saving" while it's also reloading.
But this change makes it kind of buggier that no matter how I wait, the button hangs on "saving" and the generator never saves (unlike the original that errors after 20 seconds and then reverts to the original state, allowing you to retry the save)
@perchance The picture below is a screenshot I took a few days ago.
And one more bug I want to point out, every time you click on the save button, the save function will be executed (so if you click two times, it'll be run two times), making the revisions list clogging up with multiple saves from the exact same moment (see the revisions list in the image).
Please someone ping the Dev so they'll notice about this, I'm on a different platform.
There were a few instances where in the editor ended up failing to “save”, but the generator saving process still succeeded and is still recorded in the revisions.
By 'failing' to save, the button didn't resolve to the disabled 'saved' button state, but it added a revision?
And one more bug I want to point out, every time you click on the save button, the save function will be executed (so if you click two times, it’ll be run two times), making the revisions list clogging up with multiple saves from the exact same moment (see the revisions list in the image).
I think it works as intended, since you clicked it two times, then it should return two saves. I would suggest not spamming the button xD.
Sometimes Perchance will throw a warning that saving has failed due to not being able to talk to the server.