From 2c4c1dabe0081d99c101d112d096521d734b6a00 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 15 Jul 2026 02:13:57 +0200 Subject: [PATCH] Fix refetching categories after library database cleanup GET_CATEGORIES_LIBRARY, GET_CATEGORIES_SETTINGS share the same query key in the cache. However, both select different fields. When cleaning up the database in the library settings, the SETTINGS query is active and refetches due to the cache eviction. This then wrote the query back into the cache pointing to the existing CategoryType fragments in the cache. The problem was that the SETTINGS query selects fewer fields than the LIBRARY query. Due to the query now existing again in the cache, the LIBRARY query was not refetched. Instead, it used the cached category fragments, which still included the outdated LIBRARY fields from before the eviction --- CHANGELOG.md | 1 + src/lib/requests/RequestManager.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f05fbaa..039729ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - (**Browse**) Fix not being able to select some languages as an "allowed language" in some situations (e.g., browser native language "en-GB" prevented "English" from getting visually shown as enabled) - (**Manga/Library**) Fix mark as read/unread option not being disabled for manga without any chapters - (**Manga/Library**) Fix delete/download option not being disabled for manga without any chapters +- (**Library**) Fix showing outdated category item after removing non library manga from categories - (**Source**) Fix changing configuration settings with multi option selection where a selected option does not exist anymore. (E.g. Komgas "Default libraries" setting, still having a library selected that has been deleted) - (**Download**) Fix not respecting chapter list filters for downloads - (**Download**) Fix showing outdated download info in for some chapter cards after clearing the download queue diff --git a/src/lib/requests/RequestManager.ts b/src/lib/requests/RequestManager.ts index ac5f336f..d48ce27b 100644 --- a/src/lib/requests/RequestManager.ts +++ b/src/lib/requests/RequestManager.ts @@ -2393,6 +2393,14 @@ export class RequestManager { onCompleted: () => { this.graphQLClient.client.refetchQueries({ updateCache(cache) { + const data = (cache as InMemoryCache).extract(); + + for (const [id, value] of Object.entries(data)) { + if ((value as any).__typename === 'CategoryType') { + cache.evict({ id }); + } + } + cache.evict({ fieldName: 'categories' }); cache.evict({ fieldName: 'mangas' }); }, @@ -2419,6 +2427,14 @@ export class RequestManager { response.response.then(() => { this.graphQLClient.client.refetchQueries({ updateCache(cache) { + const data = (cache as InMemoryCache).extract(); + + for (const [id, value] of Object.entries(data)) { + if ((value as any).__typename === 'CategoryType') { + cache.evict({ id }); + } + } + cache.evict({ fieldName: 'categories' }); cache.evict({ fieldName: 'mangas' }); },