From b0bd6e2c016f8b80ddfe9462ff2154d2f73fe145 Mon Sep 17 00:00:00 2001 From: Anthony LC Date: Mon, 22 Dec 2025 09:40:21 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85(frontend)=20intercept=20401=20erro?= =?UTF-8?q?r=20on=20GET=20threads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We intercept 401 errors on GET /threads to avoid spamming Sentry with authentication errors when users are not logged in. --- CHANGELOG.md | 5 ++++ .../components/comments/DocsThreadStore.tsx | 23 ++++++++++++++----- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89d1ac7b..048933fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,15 @@ and this project adheres to - ✨(helm) redirecting system #1697 - 📱(frontend) add comments for smaller device #1737 +### Changed + +- 🥅(frontend) intercept 401 error on GET threads #1754 + ### Fixed - 🐛(frontend) fix tables deletion #1752 + ## [4.2.0] - 2025-12-17 ### Added diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/DocsThreadStore.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/DocsThreadStore.tsx index 96a07d89..54b7fa4d 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/DocsThreadStore.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/comments/DocsThreadStore.tsx @@ -37,7 +37,8 @@ export class DocsThreadStore extends ThreadStore { if (docAuth.canSee) { this.awareness = awareness; this.awareness?.on('update', this.onAwarenessUpdate); - void this.refreshThreads(); + + this.refreshThreads(); } } @@ -98,9 +99,9 @@ export class DocsThreadStore extends ThreadStore { // If we know the threadId, schedule a targeted refresh. Otherwise, fall back to full refresh. if (ping.threadId) { - await this.refreshThread(ping.threadId); + void this.refreshThread(ping.threadId); } else { - await this.refreshThreads(); + this.refreshThreads(); } } }; @@ -280,7 +281,7 @@ export class DocsThreadStore extends ThreadStore { }), ); - await this.refreshThreads(); + this.refreshThreads(); return; } @@ -298,7 +299,17 @@ export class DocsThreadStore extends ThreadStore { this.notifySubscribers(); } - public async refreshThreads(): Promise { + public refreshThreads() { + this.initThreads().catch((e) => { + if (!(e instanceof APIError) || e.status !== 401) { + throw e; + } + + return; + }); + } + + public async initThreads(): Promise { const response = await fetchAPI(`documents/${this.docId}/threads/`, { method: 'GET', }); @@ -484,7 +495,7 @@ export class DocsThreadStore extends ThreadStore { ); } - await this.refreshThreads(); + this.refreshThreads(); this.ping(threadId); };