feat(throttling): add global rate limit lockout flow

This commit is contained in:
2026-04-30 15:25:45 +03:30
parent 2772b36447
commit e635fd9c2c
10 changed files with 901 additions and 279 deletions

View File

@@ -23,6 +23,7 @@ import {
} from "../api/notifications"
import { useTranslation } from "../hooks/useTranslation"
import { presentNotification } from "../lib/notificationPresenter"
import { isRateLimitActive } from "../lib/rateLimit"
import {
getAccessToken,
SESSION_CHANGED_EVENT,
@@ -171,7 +172,7 @@ export function NotificationsProvider({ children }: { children: ReactNode }) {
)
const refreshNotifications = useCallback(async () => {
if (!getAccessToken()) {
if (!getAccessToken() || isRateLimitActive()) {
setNotifications([])
setUnreadCount(0)
setTotalCount(0)
@@ -279,7 +280,7 @@ export function NotificationsProvider({ children }: { children: ReactNode }) {
}, [markAsSeen, openNotificationTarget, t.notifications])
const connectToStream = useCallback(async () => {
if (!getAccessToken()) {
if (!getAccessToken() || isRateLimitActive()) {
closeEventSource()
setConnectionStatus("idle")
return
@@ -413,7 +414,7 @@ export function NotificationsProvider({ children }: { children: ReactNode }) {
useEffect(() => {
const startNotifications = async () => {
if (!getAccessToken()) {
if (!getAccessToken() || isRateLimitActive()) {
closeEventSource()
setNotifications([])
setUnreadCount(0)