diff --git a/DynamicBibleIonic/.prettierrc b/DynamicBibleIonic/.prettierrc index 201ec7c4..368c2f1a 100644 --- a/DynamicBibleIonic/.prettierrc +++ b/DynamicBibleIonic/.prettierrc @@ -1,4 +1,4 @@ { "printWidth": 120, - "singleQuote": false + "singleQuote": true } diff --git a/DynamicBibleIonic/src/services/profile-service.ts b/DynamicBibleIonic/src/services/profile-service.ts index b976c667..f732b6fe 100644 --- a/DynamicBibleIonic/src/services/profile-service.ts +++ b/DynamicBibleIonic/src/services/profile-service.ts @@ -62,8 +62,8 @@ export class ProfileService { console.log('Saving the remote profile...'); self.remoteProfile.ref.set(self.localProfile); console.log(' Finished saving remote profile. ' + self.elapsed(st, new Date()) + 'ms'); + self.needsSync = false; } - self.needsSync = false; } poll(self); @@ -80,7 +80,9 @@ export class ProfileService { this.onLocalStorageLoaded.emit(this.localProfile); }); - this.firebaseAuth.authState.subscribe(state => this.subscribeToRemoteProfile(this.db, state)); + this.firebaseAuth.authState.subscribe(state => { + this.subscribeToRemoteProfile(this.db, state); + }); } addSearchRequestToHistory(qry: string) { @@ -141,6 +143,14 @@ export class ProfileService { } subscribeToRemoteProfile(db: AngularFireDatabase, user: firebase.User) { + // if this is a logout. + if (user === null) { + console.log('user signed out from FireBase'); + this.remoteProfile = null; // inform the profile service not to bother + this.remoteLoggedIn = false; + return; + } + console.log('subscribeToRemoteProfile'); if (!user || this.firebaseUser) return; console.log('You got the firebase user.'); @@ -208,8 +218,6 @@ export class ProfileService { authenticate() { console.log('Authenticating to remote...'); - - let self = this; let provider = new firebase.auth.GoogleAuthProvider(); if (this.isWeb) { this.firebaseAuth.auth.signInWithPopup(provider); @@ -225,7 +233,6 @@ export class ProfileService { console.log(error); }); } - this.firebaseAuth.authState.subscribe(state => this.subscribeToRemoteProfile(this.db, state)); this.remoteLoggedIn = true; }