My app is using Firebase auth with Firestore (https://github.com/angular/angularfire2). Despite my efforts to unsubscribe from all observables fetched from Firestore before signing out, I keep encountering a "FirebaseError: Missing or insufficient permissions" issue. This error seems to stem from a nested subscription within another subscription in the code snippet below.
Even after unsubscribing from both subscriptions in the ngOnDestroy method, the error persists.
this.proposalSubscription = this._posts.retrieveProposals(user.uid)
.subscribe(proposals => {
this.proposals = proposals;
this.proposals.forEach(proposal => {
this.chatSubscription = this._chat.retrieveChat(proposal.id).subscribe(chat => {
if (chat) {
this.chats.set(proposal.id, chat)
}
});
})
});
I suspect that the problem lies in this line of code:
this.chatSubscription = this._chat.retrieveChat(proposal.id).subscribe(chat => ...
Even though I ensure to unsubscribe from both proposalSubscription and chatSubscription before signing out, the error persists. Can anyone suggest a solution to this issue? Additionally, I have limited experience with rxjs and its operators. Is there an operator that can help avoid such nested subscriptions?
Any insights would be greatly appreciated. Thank you.