From fbc43b7545fa1eafb2d833564348cd365b48b814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juuso=20Piikkila=CC=88?= Date: Fri, 2 Aug 2024 11:04:49 +0300 Subject: [PATCH 1/3] feat: improve cv cache flushing --- src/index.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 9b03ffa5..7fba6467 100755 --- a/src/index.ts +++ b/src/index.ts @@ -628,13 +628,12 @@ class Storyblok { await provider.set(cacheKey, response) } - if (response.data.cv && params.token) { - if ( - params.version === 'draft' && - cacheVersions[params.token] != response.data.cv - ) { - await this.flushCache() - } + if ( + response.data.cv + && params.token + && cacheVersions[params.token] != response.data.cv + ) { + await this.flushCache() cacheVersions[params.token] = params.cv ? params.cv : response.data.cv } From 9b00e0c4a8e5c4b6f0caa1bfd3ccb0f41cbd1029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juuso=20Piikkil=C3=A4?= Date: Wed, 21 Aug 2024 13:38:02 +0300 Subject: [PATCH 2/3] refactor: update ternary --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 7fba6467..495e38dc 100755 --- a/src/index.ts +++ b/src/index.ts @@ -634,7 +634,7 @@ class Storyblok { && cacheVersions[params.token] != response.data.cv ) { await this.flushCache() - cacheVersions[params.token] = params.cv ? params.cv : response.data.cv + cacheVersions[params.token] = params.cv || response.data.cv } return resolve(response) From dd7247d8a0b1fb8bec58ed8784569faf25fc6844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juuso=20Piikkila=CC=88?= Date: Tue, 3 Sep 2024 09:20:49 +0300 Subject: [PATCH 3/3] refactor: always update cache version --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 495e38dc..2b57a75e 100755 --- a/src/index.ts +++ b/src/index.ts @@ -634,7 +634,7 @@ class Storyblok { && cacheVersions[params.token] != response.data.cv ) { await this.flushCache() - cacheVersions[params.token] = params.cv || response.data.cv + cacheVersions[params.token] = response.data.cv } return resolve(response)