1- import { full , HashId , OptionalHashId } from '@audius/sdk'
1+ import {
2+ HashId ,
3+ OptionalHashId ,
4+ type Notification as SdkNotification ,
5+ RepostNotificationActionDataTypeEnum ,
6+ RepostOfRepostNotificationActionDataTypeEnum ,
7+ SaveNotificationActionDataTypeEnum ,
8+ SaveOfRepostNotificationActionDataTypeEnum ,
9+ instanceOfCreatePlaylistNotificationActionData ,
10+ instanceOfPlaylistMilestoneNotificationActionData ,
11+ instanceOfTrackMilestoneNotificationActionData
12+ } from '@audius/sdk'
213import dayjs from 'dayjs'
314
415import { BadgeTier , type ID } from '~/models'
@@ -26,7 +37,7 @@ const getTimeAgo = (date: number) => {
2637 return 'A few moments ago'
2738}
2839
29- function formatBaseNotification ( notification : full . Notification ) {
40+ function formatBaseNotification ( notification : SdkNotification ) {
3041 const timestamp = notification . actions [ 0 ] . timestamp
3142 return {
3243 groupId : notification . groupId ,
@@ -39,11 +50,10 @@ function formatBaseNotification(notification: full.Notification) {
3950
4051const toEntityType = (
4152 type :
42- | full . SaveOfRepostNotificationActionDataTypeEnum
43- | full . SaveNotificationActionDataTypeEnum
44- | full . RepostNotificationActionDataTypeEnum
45- | full . RepostOfRepostNotificationActionDataTypeEnum
46- | full . SaveOfRepostNotificationActionDataTypeEnum
53+ | SaveOfRepostNotificationActionDataTypeEnum
54+ | SaveNotificationActionDataTypeEnum
55+ | RepostNotificationActionDataTypeEnum
56+ | RepostOfRepostNotificationActionDataTypeEnum
4757) => {
4858 if ( type === 'track' ) {
4959 return Entity . Track
@@ -60,7 +70,7 @@ const toEntityType = (
6070 * and other nuanced things on a per notification basis.
6171 */
6272export const notificationFromSDK = (
63- notification : full . Notification
73+ notification : SdkNotification
6474) : Notification | undefined => {
6575 switch ( notification . type ) {
6676 case 'follow' : {
@@ -200,7 +210,7 @@ export const notificationFromSDK = (
200210 const entityIds = notification . actions
201211 . map ( ( action ) => {
202212 const data = action . data
203- if ( full . instanceOfCreatePlaylistNotificationActionData ( data ) ) {
213+ if ( instanceOfCreatePlaylistNotificationActionData ( data ) ) {
204214 entityType = data . isAlbum ? Entity . Album : Entity . Playlist
205215 // Future proofing for when playlistId is fixed to be a string
206216 return HashId . parse (
@@ -295,7 +305,7 @@ export const notificationFromSDK = (
295305 }
296306 case 'milestone' : {
297307 const data = notification . actions [ 0 ] . data
298- if ( full . instanceOfTrackMilestoneNotificationActionData ( data ) ) {
308+ if ( instanceOfTrackMilestoneNotificationActionData ( data ) ) {
299309 let achievement : Achievement
300310 if ( data . type === 'track_repost_count' ) {
301311 achievement = Achievement . Reposts
@@ -312,7 +322,7 @@ export const notificationFromSDK = (
312322 achievement,
313323 ...formatBaseNotification ( notification )
314324 }
315- } else if ( full . instanceOfPlaylistMilestoneNotificationActionData ( data ) ) {
325+ } else if ( instanceOfPlaylistMilestoneNotificationActionData ( data ) ) {
316326 let achievement : Achievement
317327 if ( data . type === 'playlist_repost_count' ) {
318328 achievement = Achievement . Reposts
@@ -641,5 +651,7 @@ export const notificationFromSDK = (
641651 ...formatBaseNotification ( notification )
642652 }
643653 }
654+ default :
655+ return undefined
644656 }
645657}
0 commit comments