diff --git a/src/containers/UserInformation/UserInformation.tsx b/src/containers/UserInformation/UserInformation.tsx index c228e9e8..a054717d 100644 --- a/src/containers/UserInformation/UserInformation.tsx +++ b/src/containers/UserInformation/UserInformation.tsx @@ -18,6 +18,8 @@ import { } from './constants' import { NotificationsAPI, checkIsOnboarding, parseNotification} from '../../modules/notifications' +const NOTIFICATIONS_QUERY_INTERVAL = 60000; + export const UserInformation = (props: Props) => { const analytics = getAnalytics() @@ -32,9 +34,9 @@ export const UserInformation = (props: Props) => { ...rest } = props - const [{ isLoading, notifications }, setUserNotifications] = useState<{ notifications: DCLNotification[], isLoading: boolean}>({ + const [{ isLoading, notifications }, setUserNotifications] = useState({ isLoading: false, - notifications: [] + notifications: [] as DCLNotification[] }) const [notificationsState, setNotificationsState] = useState({ activeTab: NotificationActiveTab.NEWEST, @@ -129,7 +131,7 @@ export const UserInformation = (props: Props) => { const fetchNotificationsState = () => { setUserNotifications({ notifications, isLoading: true }) - client.getNotifications(50) + client.getNotifications() .then((response) => { const parsed = response.notifications.map(parseNotification) @@ -166,7 +168,7 @@ export const UserInformation = (props: Props) => { if (identity && withNotifications) { const interval = setInterval(() => { fetchNotificationsState() - }, 60000) + }, NOTIFICATIONS_QUERY_INTERVAL) return () => { clearInterval(interval) diff --git a/src/modules/notifications.ts b/src/modules/notifications.ts index 614c5e01..c58871d0 100644 --- a/src/modules/notifications.ts +++ b/src/modules/notifications.ts @@ -2,6 +2,7 @@ import { getEnv, Env } from "@dcl/ui-env"; import { BaseClient, BaseClientConfig } from "../lib/BaseClient"; import { DCLNotification } from "decentraland-ui/dist/components/Notifications/types" +export const NOTIFICATIONS_LIMIT = 50; export class NotificationsAPI extends BaseClient { constructor(config: BaseClientConfig) { @@ -10,7 +11,7 @@ export class NotificationsAPI extends BaseClient { super(url, config) } - async getNotifications(limit?: number, from?: number) { + async getNotifications(limit: number = NOTIFICATIONS_LIMIT, from?: number) { const params = new URLSearchParams() if (limit) {