feat(throttling): add global rate limit lockout flow
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user