Hello im using virtual scroller for loading items like this :
onScroll() {
if(this.posts){
this.postsOffset++;
this.apiService.getUsersPosts(this.profileLink,this.postsOffset.toString()).subscribe(res => {
if(res){
this.posts= this.posts.concat(res.data);
}
});
}
}
so everytime user scroll offset is increased
but now i want to handle removing items from it, i tried this way (this function is called right after deleting record from DB)
removePost(post) {
this.posts= this.posts.filter(pst=> pst.id != post.id);
this.user.posts-=1;
}
currently it is not working as i would like to, there are always missing items comming back from API
im looking for way to do this without requesting this data again.
api (spring boot)
postRepository.findByUser_ProfileLink(userLink, PageRequest.of(offset, 3,Sort.by("createdAt").descending())).getContent().stream().map(s-> new PostResponseDTO(s)).collect(Collectors.toList());