I am currently developing an application with a page structure that resembles the following:
Displaying Objects retrieved from Firestore (similar to Instagram posts)
- Loading Comments (using the object's id to display comments sub-collection)
- Loading Replies (using the object and comment id to display replies sub-collection)
Here is a simplified version of the code:
<div class="container">
{{ object.data.text }}
{{ object.data.likes.length }}
<comment objectid="{{object.id}}">
</div>
Comment selector
A simplified version of the comment template:
<div *ngFor="let comment of comments | async" class="container">
{{ comment.data.text }}
{{ comment.data.likes.length }}
<reply commentid="{{comment.id}}">
</div>
Replies selector
A simplified version of the reply template:
<div *ngFor="let reply of replies | async" class="container">
{{ comment.data.text }}
</div>
Issue: When the number of likes in comment.data.length changes for the object, the reply selector goes through the full ngOnInit and ngOnDestroy lifecycle. However, when the number of likes in object.data.length changes, there is no lifecycle trigger for the comment or reply selector. This results in the replies being refreshed every time a user likes a comment, which is not ideal.
Has anyone encountered this issue before or knows how to resolve it?