diff --git a/app.json b/app.json index eb3aa46..8cb3ce3 100644 --- a/app.json +++ b/app.json @@ -10,7 +10,7 @@ "ios", "android" ], - "version": "0.7.1", + "version": "0.8.0", "orientation": "portrait", "icon": "./assets/images/icon.png", "splash": { diff --git a/src/NotificationsHandler.js b/src/NotificationsHandler.js index 860cdc4..1cb23a1 100644 --- a/src/NotificationsHandler.js +++ b/src/NotificationsHandler.js @@ -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) => { @@ -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 } @@ -58,7 +69,13 @@ 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) => { @@ -66,6 +83,11 @@ export default class NotificationsHandler { 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