Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix): ensure new chapter list is merged properly
- previously, the new chapter list would just overwrite the old, persisted one - but the read/unread & new tracking meant the two lists had to be merged, and the previous merge logic was causing bugs that are fixed here - for any manga that were persisted, new chapters wouldn't appear in the chapter list - it would only show the ones that were persisted - this is apparently bc MST was swallowing an error when a node is used more than once in the tree - instead of updating each entry in the chapter list as we go, just update the whole list at once with tne new one - and do merging out of tree before updating - fix the incorrect logic that merged via indices - for one thing, chapters are in reverse chronological order, so when a new chapter is released old[0] will be equal to new[1], as new[0] is the new chapter - the previous logic merged old[0] with new[0], which is super broken (woops) - instead merge via `link`, which is the MST identifier of a chapter and therefore must be unique - currently assuming that the chapters are still ordered the same way, so we don't have to search the entire list to see if the chapter exists and instead move an offset as needed - this is somewhat of an over-optimization, and it falls relatively hard if a chapter were released in between old chapters like a 0.5, an uncensored, diff translation, etc - TODO: optimal fix is to have a map of chapters, update the map entries, and then the list is just the ordering of refs - would be somewhat similar to how mangas are stored - this breaks the stored model data though, so it requires a migration, and those aren't yet implemented in mst-persist, and nor are transforms to workaround the lack of it
- Loading branch information