Cache fixes (#1048)

* Bust cache for studio/tag image updates
* Reset cache when a scan/clean has been run
This commit is contained in:
InfiniteTF
2021-01-12 05:03:50 +01:00
committed by GitHub
parent 03a9d65cfe
commit 0a123548a0
4 changed files with 30 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
* Allow configuration of visible navbar items.
### 🎨 Improvements
* Reset cache after scan/clean to ensure scenes are updated.
* Add more video/image resolution tags.
* Add option to strip file extension from scene title when populating from scanning task.
* Pagination support and general improvements for image lightbox.
@@ -20,6 +21,7 @@
* Support configurable number of threads for scanning and generation.
### 🐛 Bug fixes
* Fix tag/studio images not being changed after update.
* Fixed resolution tags and querying for portrait videos and images.
* Corrected file sizes on 32bit platforms
* Fixed login redirect to remember the current page.

View File

@@ -134,6 +134,10 @@ export const Studio: React.FC = () => {
input: getStudioInput() as GQL.StudioUpdateInput,
},
});
if (result.data?.studioUpdate?.image_path)
await fetch(result.data?.studioUpdate?.image_path, {
cache: "reload",
});
if (result.data?.studioUpdate) {
updateStudioData(result.data.studioUpdate);
setIsEditing(false);

View File

@@ -133,6 +133,8 @@ export const Tag: React.FC = () => {
},
});
if (result.data?.tagUpdate) {
if (result.data.tagUpdate.image_path)
await fetch(result.data.tagUpdate.image_path, { cache: "reload" });
updateTagData(result.data.tagUpdate);
setIsEditing(false);
}

View File

@@ -10,6 +10,7 @@ import { WebSocketLink } from "@apollo/client/link/ws";
import { onError } from "@apollo/client/link/error";
import { getMainDefinition } from "@apollo/client/utilities";
import { createUploadLink } from "apollo-upload-client";
import * as GQL from "src/core/generated-graphql";
// Policies that tell apollo what the type of the returned object will be.
// In many cases this allows it to return from cache immediately rather than fetching.
@@ -140,6 +141,27 @@ export const createClient = () => {
cache,
});
// Watch for scan/clean tasks and reset cache when they complete
let prevStatus = "Idle";
client
.subscribe<GQL.MetadataUpdateSubscription>({
query: GQL.MetadataUpdateDocument,
})
.subscribe({
next: (res) => {
const currentStatus = res.data?.metadataUpdate.status;
if (currentStatus) {
if (
currentStatus === "Idle" &&
(prevStatus === "Scan" || prevStatus === "Clean")
) {
client.resetStore();
}
prevStatus = currentStatus;
}
},
});
return {
cache,
client,