Skip to content

Commit

Permalink
feat(notifications): notification added on message recieved
Browse files Browse the repository at this point in the history
  • Loading branch information
Jekrimo committed Apr 20, 2022
1 parent e43c60e commit f56e855
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion libraries/Textile/NotificationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class NotificationManager {
id: '',
message,
seen: false,
from: this.textile.wallet.address,
from,
type,
date: Date.now(),
}
Expand All @@ -104,6 +104,7 @@ export class NotificationManager {
CollectionName,
Query.where('_id').eq(notificationId[0]),
)
console.log(notification, 'noti')
return notification[0]
}

Expand Down
17 changes: 11 additions & 6 deletions store/textile/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
SearchOrderType,
UISearchResultData,
} from '~/types/search/search'
import { UIState } from '~/store/ui/types'
import InitialUIState from '~/store/ui/state'

const getGroupChatProgram = (): GroupChatsProgram => {
const $SolanaManager: SolanaManager = Vue.prototype.$SolanaManager
Expand Down Expand Up @@ -206,18 +208,21 @@ export default {
if (!sender) {
return
}

commit('addMessageToConversation', {
address: sender.address,
sender: MessageRouteEnum.INBOUND,
message,
})

dispatch('ui/sendNotification', {
message: `new message from ${message.from}`,
from: message.from,
type: NotificationTypes.DIRECT_MESSAGE,
})
dispatch(
'ui/sendNotification',
{
message: `New message from ${sender.name}`,
from: message.from,
type: NotificationTypes.DIRECT_MESSAGE,
},
{ root: true },
)

dispatch('storeInMessage', { address: sender.address, message })
})
Expand Down
1 change: 1 addition & 0 deletions store/ui/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default {
notificationMessage,
type,
)
console.log(notificationResponse)
commit('sendNotification', notificationResponse)
},
clearAllNotifications({ commit, rootState }: ActionsArguments<UIState>) {
Expand Down

0 comments on commit f56e855

Please sign in to comment.