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
This commit is contained in:
schroda
2026-07-15 02:13:57 +02:00
parent e76de477a3
commit 2c4c1dabe0
2 changed files with 17 additions and 0 deletions

View File

@@ -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) - (**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 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 - (**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) - (**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 not respecting chapter list filters for downloads
- (**Download**) Fix showing outdated download info in for some chapter cards after clearing the download queue - (**Download**) Fix showing outdated download info in for some chapter cards after clearing the download queue

View File

@@ -2393,6 +2393,14 @@ export class RequestManager {
onCompleted: () => { onCompleted: () => {
this.graphQLClient.client.refetchQueries({ this.graphQLClient.client.refetchQueries({
updateCache(cache) { 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: 'categories' });
cache.evict({ fieldName: 'mangas' }); cache.evict({ fieldName: 'mangas' });
}, },
@@ -2419,6 +2427,14 @@ export class RequestManager {
response.response.then(() => { response.response.then(() => {
this.graphQLClient.client.refetchQueries({ this.graphQLClient.client.refetchQueries({
updateCache(cache) { 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: 'categories' });
cache.evict({ fieldName: 'mangas' }); cache.evict({ fieldName: 'mangas' });
}, },