Skip to content

Commit

Permalink
tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
andygray committed Dec 2, 2019
1 parent 5e7e837 commit 048bcc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Firebase/CryptoKitties/KittiesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions src/components/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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());
Expand Down

0 comments on commit 048bcc8

Please sign in to comment.