From 7432e475b852a73d4d48de50c03c8b09c785e8ac Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Wed, 18 Oct 2023 10:50:52 +0200 Subject: [PATCH 1/3] Fix console error --- .../app/site/services/view-model-store-update.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/app/site/services/view-model-store-update.service.ts b/client/src/app/site/services/view-model-store-update.service.ts index ba9f323bfa..62a978973b 100644 --- a/client/src/app/site/services/view-model-store-update.service.ts +++ b/client/src/app/site/services/view-model-store-update.service.ts @@ -65,10 +65,11 @@ export class ViewModelStoreUpdateService { } for (const collection of Object.keys(changedModels)) { - const modelIds = - this.DS.get(changedModels[collection].parentCollection, changedModels[collection].parentId)[ - changedModels[collection].parentField - ] || []; + const parentModel = this.DS.get( + changedModels[collection].parentCollection, + changedModels[collection].parentId + ); + const modelIds = (parentModel && parentModel[changedModels[collection].parentField]) || []; const ids = modelIds.difference(changedModels[collection].ids); _deletedModels[collection] = (_deletedModels[collection] || []).concat(ids); } From 66dfe23a11cedbfc2b420913f87e33ebeb963f7b Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Wed, 18 Oct 2023 12:53:18 +0200 Subject: [PATCH 2/3] Handle status code 200 autoupdate errors --- .../src/app/worker/autoupdate/autoupdate-stream.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/app/worker/autoupdate/autoupdate-stream.ts b/client/src/app/worker/autoupdate/autoupdate-stream.ts index 4ec12ae9c2..3f54c387e0 100644 --- a/client/src/app/worker/autoupdate/autoupdate-stream.ts +++ b/client/src/app/worker/autoupdate/autoupdate-stream.ts @@ -254,18 +254,22 @@ export class AutoupdateStream { } } - if (!response.ok) { - if (headers.authentication !== this.authToken) { + // Hotfix wrong status codes + const content = next && this.parse(this.decode(next)); + const autoupdateSentUnmarkedError = content?.type !== ErrorType.UNKNOWN && content?.error; + + if (!response.ok || autoupdateSentUnmarkedError) { + if (headers.authentication ?? null !== this.authToken ?? null) { return await this.doRequest(); } let errorContent = null; - if (next && (errorContent = this.parse(this.decode(next)))?.error) { + if (next && (errorContent = content?.error)) { errorContent = errorContent.error; } let type = ErrorType.UNKNOWN; - if (response.status >= 400 && response.status < 500) { + if ((response.status >= 400 && response.status < 500) || errorContent?.type === `invalid`) { type = ErrorType.CLIENT; } else if (response.status >= 500) { type = ErrorType.SERVER; From cc7e33f1b9d2942f27973a445a554c7c53adcf64 Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Fri, 20 Oct 2023 14:56:33 +0200 Subject: [PATCH 3/3] Fix session invalidation --- client/src/app/worker/autoupdate/autoupdate-stream.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/app/worker/autoupdate/autoupdate-stream.ts b/client/src/app/worker/autoupdate/autoupdate-stream.ts index 3f54c387e0..e548e91a53 100644 --- a/client/src/app/worker/autoupdate/autoupdate-stream.ts +++ b/client/src/app/worker/autoupdate/autoupdate-stream.ts @@ -255,16 +255,16 @@ export class AutoupdateStream { } // Hotfix wrong status codes - const content = next && this.parse(this.decode(next)); + const content = next ? this.parse(this.decode(next)) : null; const autoupdateSentUnmarkedError = content?.type !== ErrorType.UNKNOWN && content?.error; if (!response.ok || autoupdateSentUnmarkedError) { - if (headers.authentication ?? null !== this.authToken ?? null) { + if ((headers.authentication ?? null) !== (this.authToken ?? null)) { return await this.doRequest(); } let errorContent = null; - if (next && (errorContent = content?.error)) { + if (content && (errorContent = content)?.error) { errorContent = errorContent.error; }