I have an active observer that will refresh the tableview when new data comes in.
ref.child(live_mode).queryOrderedByKey().queryLimited(toLast: 200).observe(.childAdded, with: {snapshot in
self.posts.insert(PostFeed(uid: uid , profile_image_url: profile_image_url, profile_name: profile_name, post_id: post_id, post_title: post_title, post_text: post_text, post_type: post_type, youtube_video_url: youtube_video_url, youtube_video_id: youtube_video_id, youtube_image_url: youtube_image_url, time_stamp: time_stamp, like_count: "0"), at: 0)
DispatchQueue.main.async {
self.tableView.reloadData()
}
})
I would like the table view to be un-interupted or unrefreshed based on one saved indexPath. Meaning I would like the tableView to be reloaded but I dont want an individual cell reloaded since its playing a video.
savedIndex = indexPath // cell to not be reloaded since playing video
What is the best way to reload the tableView when new data comes in but without interrupting the saved index cell that would be showing a video?
>Solution :
Use the API to insert single rows
ref.child(live_mode).queryOrderedByKey().queryLimited(toLast: 200).observe(.childAdded, with: {snapshot in
self.posts.insert(PostFeed(uid: uid , profile_image_url: profile_image_url, profile_name: profile_name, post_id: post_id, post_title: post_title, post_text: post_text, post_type: post_type, youtube_video_url: youtube_video_url, youtube_video_id: youtube_video_id, youtube_image_url: youtube_image_url, time_stamp: time_stamp, like_count: "0"), at: 0)
DispatchQueue.main.async {
self.tableView.insertRows(at: [IndexPath(row: O, section: 0)], with: .automatic)
}
})
The other cells are not affected, and you get a nice animation for free.
If the section is not 0, specify the proper section index.