Skip to content

Potentially extraneous requests for random comics for items #74

@ilyvion

Description

@ilyvion

When switching to the next comic, a request for a new random comic gets made by the NavElement immediately when currentComic changes because it becomes a different request here:

useRandomComicQuery(
mode === NavElementMode.Present && settings?.showItemRandomButton
? {
currentComic,
itemId: item.id,
skipGuest: settings.skipGuest,
skipNonCanon: settings.skipNonCanon,
}
: skipToken
)

This request happens before we even know if that item is going to be in the next comic, and so it might be a "wasted" request.

Potential solutions that I can think of are:

  • Find a way to hold off on asking for a new random comic until all the data for the next comic has been loaded. This can be achieved through adding a new state value for lastFullyLoadedComicId or something, and using it for requesting a new random comic instead
  • Don't include the currentComic in the request for a random comic at all, and instead re-request a random comic on the client side if the returned comic happens to be the same as the current one (avoiding this is currently handled server side which is why the current comic gets passed down). A potential problem here is that if the comic only appears in a single comic (the current one) this could lead to infinite looping if not handled carefully.

Metadata

Metadata

Assignees

Labels

bugSomething that is not behaving is expected or prevents use entirely

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions