Final gist integration + clean up
This commit is contained in:
@@ -36,6 +36,7 @@ export class FirebaseInstance {
|
||||
this.app.auth().onAuthStateChanged((user) => {
|
||||
if (user) {
|
||||
this.currentUser = user
|
||||
|
||||
this.currentUser.providerData.forEach((profile) => {
|
||||
let us = {
|
||||
updatedOn: new Date(),
|
||||
@@ -47,10 +48,15 @@ export class FirebaseInstance {
|
||||
}
|
||||
this.usersCollection
|
||||
.doc(this.currentUser.uid)
|
||||
.set(us)
|
||||
.set(us, { merge: true })
|
||||
.catch((e) => console.error("error updating", us, e))
|
||||
})
|
||||
|
||||
this.usersCollection.doc(this.currentUser.uid).onSnapshot((doc) => {
|
||||
this.currentUser.provider = doc.data().provider
|
||||
this.currentUser.accessToken = doc.data().accessToken
|
||||
})
|
||||
|
||||
this.usersCollection
|
||||
.doc(this.currentUser.uid)
|
||||
.collection("feeds")
|
||||
@@ -288,6 +294,24 @@ export class FirebaseInstance {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
async setProviderInfo(id, token) {
|
||||
const us = {
|
||||
updatedOn: new Date(),
|
||||
provider: id,
|
||||
accessToken: token,
|
||||
}
|
||||
try {
|
||||
await this.usersCollection
|
||||
.doc(this.currentUser.uid)
|
||||
.update(us)
|
||||
.catch((e) => console.error("error updating", us, e))
|
||||
} catch (e) {
|
||||
console.error("error updating", ev, e)
|
||||
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const fb = new FirebaseInstance(firebase.initializeApp(firebaseConfig), authProviders)
|
||||
|
||||
Reference in New Issue
Block a user