Skip to content

Commit

Permalink
feat: Handle event join approved notification
Browse files Browse the repository at this point in the history
  • Loading branch information
kachnitel committed Dec 29, 2019
1 parent 89be0a7 commit 1e31939
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"ios",
"android"
],
"version": "0.7.1",
"version": "0.8.0",
"orientation": "portrait",
"icon": "./assets/images/icon.png",
"splash": {
Expand Down
24 changes: 23 additions & 1 deletion src/NotificationsHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import navigationService from './NavigationService'
import stores from './stores/CollectionStores.singleton'
import { Event } from './stores/EventStore.mobx'

export default class NotificationsHandler {
listener = (notification: Object) => {
Expand Down Expand Up @@ -30,6 +31,16 @@ export default class NotificationsHandler {
// TODO: open screen with `showMessages` param
screenParams = { eventId: notification.data.event.id }
break
case 'eventOwnRequestAccepted':
callback = this.handleEventOwnRequestAccepted
screen = 'RideDetail'
screenParams = { eventId: notification.data.event.id }
break
case 'eventJoinRequested':
callback = this.handleEventJoinRequested
screen = 'RideDetail'
screenParams = { eventId: notification.data.event.id }
break
default:
return
}
Expand Down Expand Up @@ -58,14 +69,25 @@ export default class NotificationsHandler {
}

handleEventMemberJoined = (data) => {
stores.event.upsert(data.event)
let event: Event = stores.event.upsert(data.event)
event.members.map((id) => { event.requested.includes(id) && event.requested.remove(id) })
}

handleEventOwnRequestAccepted = (data) => {
let event: Event = stores.event.upsert(data.event)
stores.event.removeSentRequest(event.id)
}

handleEventCommentAdded = (data) => {
stores.event.upsert(data.event)
stores.comment.upsert(data.comment)
}

handleEventJoinRequested = (data) => {
let event: Event = stores.event.upsert(data.event)
event.addRequested(data.from)
}

/**
* Check whether current user is loaded
* Calls callback if it is, otherwise redirects to AuthLoading first
Expand Down

0 comments on commit 1e31939

Please sign in to comment.