-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6109ff3
commit 99b13b4
Showing
9 changed files
with
106 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
//Constants | ||
import { channelNotifications } from '../../queryKeys'; | ||
|
||
//Services | ||
import { getChannelNotifications } from '../../services'; | ||
|
||
//Types | ||
import { UserStoreType } from 'types'; | ||
import { GuestWalletAddress } from 'common'; | ||
|
||
export const useGetChannelNotifications = (address: string, page: number, limit: number) => { | ||
const { userPushSDKInstance } = useSelector((state: UserStoreType) => { | ||
return state.user; | ||
}); | ||
const query = useQuery({ | ||
queryKey: [channelNotifications, address], | ||
queryFn: () => getChannelNotifications({ userPushSDKInstance, address, page, limit }), | ||
enabled: address !== GuestWalletAddress, // This is required to avoid extra func calls | ||
}); | ||
return query; | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/queries/models/channels/getChannelNotificationsModelCreator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ChannelNotification, ChannelsNotificationsRepsonse } from 'queries/types'; | ||
|
||
//any remodelling needed in the response can be done here | ||
export const getChannelNotificationsModelCreator = (response: ChannelsNotificationsRepsonse): ChannelNotification[] => | ||
response?.notifications; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { PushAPI } from '@pushprotocol/restapi'; | ||
|
||
import { getChannelNotificationsModelCreator } from '../../models'; | ||
|
||
type GetChannelNotificationsParams = { | ||
userPushSDKInstance: PushAPI; | ||
address: string; | ||
limit: number; | ||
page: number; | ||
}; | ||
|
||
export const getChannelNotifications = ({ userPushSDKInstance, address, limit, page }: GetChannelNotificationsParams) => | ||
userPushSDKInstance.channel | ||
.notifications(address, { | ||
page: page, | ||
limit: limit, | ||
}) | ||
.then(getChannelNotificationsModelCreator); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters