From 1e3193952ac9ab7b095deb1309db18bce73bd7bd Mon Sep 17 00:00:00 2001 From: Ondrej Vana Date: Sat, 28 Dec 2019 22:37:15 -0800 Subject: [PATCH] feat: Handle event join approved notification --- app.json | 2 +- src/NotificationsHandler.js | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) 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