-
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.
- Loading branch information
Showing
6 changed files
with
176 additions
and
33 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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# General | ||
src/_config/ | ||
|
||
.DS_Store | ||
node_modules | ||
/dist | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,45 @@ | ||
import {db} from './index'; | ||
|
||
// todo: check that address is valid before firing any query | ||
export default new class Accounts { | ||
async upsertAccount(account) { | ||
return db | ||
.collection('accounts') | ||
.doc(account.address) | ||
.set(account, { | ||
merge: true | ||
}); | ||
} | ||
|
||
async getAccount(address) { | ||
return db | ||
.collection('accounts') | ||
.doc(address) | ||
.get() | ||
.then(snapshot => { | ||
if(snapshot.exists) { | ||
return snapshot.data(); | ||
} | ||
return null; | ||
}); | ||
} | ||
|
||
async upsertFirebaseMessagingTokenForAccount(address, firebaseMessagingToken) { | ||
return db | ||
.collection('accounts') | ||
.doc(address) | ||
.set({firebaseMessagingToken}, { | ||
merge: true | ||
}); | ||
} | ||
|
||
async getFirebaseMessagingTokenForAccount(address) { | ||
return this.getAccount(address) | ||
.then(account => { | ||
if(account && account.firebaseMessagingToken) { | ||
return account.firebaseMessagingToken; | ||
} | ||
return null; | ||
}); | ||
} | ||
} |
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,12 @@ | ||
const firebase = require('firebase'); | ||
require("firebase/firestore"); | ||
require("firebase/messaging"); | ||
|
||
const {firebaseConfig} = require('../_config/env'); | ||
|
||
firebase.initializeApp(firebaseConfig); | ||
|
||
module.exports = { | ||
db: firebase.firestore(), | ||
messaging: firebase.messaging() | ||
}; |
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