-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstracted CryptoKitties firebase methods into its own service ready …
…for extraction
- Loading branch information
Showing
2 changed files
with
52 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// todo: change this path when imported into the CK tinder app | ||
import {db} from '../index'; | ||
|
||
export default new class KittiesService { | ||
async getAllKittiesForAddress(network, address) { | ||
return await db.collection('kitties') | ||
.doc('network') | ||
.collection(network) | ||
.where('owner', '==', address) | ||
.get() | ||
.then(snapshots => { | ||
if (snapshots.empty) { | ||
return []; | ||
} | ||
return snapshots.docs.map(doc => doc.id); | ||
}); | ||
} | ||
|
||
async poke(pokeId, kittieId, message, from, studId) { | ||
return db.collection('kitties') | ||
.doc('network') | ||
.collection('mainnet') | ||
.doc(kittieId) | ||
.collection('poke') | ||
.doc(pokeId) | ||
.set({msg: message, from, stud: studId}, { | ||
merge: true | ||
}); | ||
} | ||
|
||
async swipeRight(kittieId, studId, message, from) { | ||
return db.collection('kitties') | ||
.doc('network') | ||
.collection('mainnet') | ||
.doc(kittieId) | ||
.collection('swipeRight') | ||
.doc(studId) | ||
.set({msg: message, from, stud: studId}, { | ||
merge: true | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters