Skip to content

Commit

Permalink
fix: improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
lauti7 committed Dec 7, 2023
1 parent 4a91705 commit 605cbff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/containers/UserInformation/UserInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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,
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -166,7 +168,7 @@ export const UserInformation = (props: Props) => {
if (identity && withNotifications) {
const interval = setInterval(() => {
fetchNotificationsState()
}, 60000)
}, NOTIFICATIONS_QUERY_INTERVAL)

return () => {
clearInterval(interval)
Expand Down
3 changes: 2 additions & 1 deletion src/modules/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 605cbff

Please sign in to comment.