🥅(frontend) intercept 401 error on GET threads

We intercept 401 errors on GET /threads to avoid
spamming Sentry with authentication errors
when users are not logged in.
This commit is contained in:
Anthony LC
2025-12-22 09:40:21 +01:00
parent 37527416f2
commit b0bd6e2c01
2 changed files with 22 additions and 6 deletions

View File

@@ -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

View File

@@ -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<void> {
public refreshThreads() {
this.initThreads().catch((e) => {
if (!(e instanceof APIError) || e.status !== 401) {
throw e;
}
return;
});
}
public async initThreads(): Promise<void> {
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);
};