Oh awesome, so they do preload. Thanks for checking!
Thank you for looking into this! I just took the WK announcement at face value and assumed that one subject data is fetched after every completed review. But now I’m wondering if userscripts have any way to utilize the memo object. When I prepared my Later Crabigator userscript for this change, I decided to fetch the next subject data to fill up the activeQueue myself whenever the script’s button is used. Not only does this lead to a small delay, but I think the item I removed from the activeQueue stays in memo – after doing this 20 times, Object.keys(memo).length will never be less than 20, so the preload into memo will never be triggered again.
Does anyone have a suggestion how to avoid this?
I’m currently trying to figure out something similar. I’m working on updating the reorder script to be compatible with the new changes (although at this point I’m just remaking it from scratch). The initial reorder rebuilds the activeQueue, so my initial approach was just recreating all items in the activeQueue using data from the API, which leads to the same problem if someone reorders a queue more than once. I’m trying to figure out if there’s a better way to modify the queue than just rebuilding it entirely, taking advantage of the items that are already loaded would be more efficient.
@BIsTheAnswer @Sinyaven One hackish solution would be to override a method that gets called on the memo array, maybe the Array.prototype.length method for example, with a version that returns the length but also saves a reference to the array. Then once you have a reference to the memo array, you can ensure it is properly updated when your script changes the activeQueue. Or maybe @WaniKaniJavi could publicly expose a method for doing this (or even better, a method for removing items from the activeQueue which properly updates the cache and a method for adding/removing items from the cache that are not already in the activeQueue)?
If you go with the hackish route, maybe it would make sense to integrate it into a library so that if it breaks, only the library needs to be updated rather than every scripts different implementation.
I’ve used a hack like this before in my load faster script to get a list of the event listeners (including those registered before my script loads) even though jStorage does not directly provide the ability to access the list of existing listeners.