From 048bcc86b9eb2c3ab8e0e36169ef8de1d89baf04 Mon Sep 17 00:00:00 2001 From: Andy Gray Date: Mon, 2 Dec 2019 15:17:24 +0000 Subject: [PATCH] tidying --- src/Firebase/CryptoKitties/KittiesService.js | 12 ++++++------ src/components/Chat.vue | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Firebase/CryptoKitties/KittiesService.js b/src/Firebase/CryptoKitties/KittiesService.js index 54361ac..16beb42 100644 --- a/src/Firebase/CryptoKitties/KittiesService.js +++ b/src/Firebase/CryptoKitties/KittiesService.js @@ -82,21 +82,21 @@ export default new class KittiesService { })); } - async matchKitties(network, studId, otherKittieId) { + async matchKitties(network, studId, kittieId) { const timestamp = Math.floor(Date.now() / 1000); const matchData = { studId, - otherKittieId, + kittieId, timestamp }; const networkRef = db.collection('kitties').doc('network').collection(network); - const studMatchDataRef = networkRef.doc(studId).collection('match').doc(otherKittieId); - const otherMatchDataRef = networkRef.doc(otherKittieId).collection('match').doc(studId); + const studMatchDataRef = networkRef.doc(studId).collection('match').doc(kittieId); + const otherMatchDataRef = networkRef.doc(kittieId).collection('match').doc(studId); - const otherSwipeRightIncomingDataRef = networkRef.doc(otherKittieId).collection('swipeRightIncoming').doc(studId); - const otherSwipeRightOutgoingDataRef = networkRef.doc(studId).collection('swipeRightOutgoing').doc(otherKittieId); + const otherSwipeRightIncomingDataRef = networkRef.doc(kittieId).collection('swipeRightIncoming').doc(studId); + const otherSwipeRightOutgoingDataRef = networkRef.doc(studId).collection('swipeRightOutgoing').doc(kittieId); await db.runTransaction(t => { t.set(studMatchDataRef, matchData); diff --git a/src/components/Chat.vue b/src/components/Chat.vue index fd9856a..8816aea 100644 --- a/src/components/Chat.vue +++ b/src/components/Chat.vue @@ -185,6 +185,9 @@ }, upsertKittiesAndGetSwipeRights: async function (kitties) { await KittiesService.upsertKitties('mainnet', kitties); + this.getSwipeRights() + }, + getSwipeRights: async function () { this.kitties.user = await KittiesService.getAllKittiesWithSwipeRightsForAddress('mainnet', this.accounts.user.toLowerCase()); this.kitties.userSelected = this.kitties.user[0].id.toString(); console.log(this.kitties.user); @@ -196,11 +199,15 @@ async mounted() { messaging.onMessage((payload) => { console.log('Message received:', payload); + + // in foreground const {title, body, icon} = payload.data; new Notification(title, { body, icon }); + + this.getSwipeRights(); }); messaging.onTokenRefresh(() => this.getFCMToken());