in fcm-notifications/public/main.js [43:77]
Demo.prototype.onAuthStateChanged = function(user) {
// If this is just an ID token refresh we exit.
if (user && this.currentUid === user.uid) {
return;
}
// Remove all Firebase realtime database listeners.
if (this.listeners) {
this.listeners.forEach(function(ref) {
ref.off();
});
}
this.listeners = [];
// Adjust UI depending on user state.
if (user) {
this.nameContainer.innerText = user.displayName;
this.signedOutCard.style.display = 'none';
this.signedInCard.style.display = 'block';
this.usersCard.style.display = 'block';
firebase.database().ref(`users/${user.uid}`).update({
displayName: user.displayName,
photoURL: user.photoURL
});
this.saveToken();
this.displayAllUsers();
this.currentUid = user.uid;
} else {
this.signedOutCard.style.display = 'block';
this.signedInCard.style.display = 'none';
this.usersCard.style.display = 'none';
this.usersContainer.innerHTML = '';
this.currentUid = null;
}
};