You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the best way to update HitsTableViewController after an add/delete/edit? Say that I have an index of items, and one of them is deleted from Algolia. I can use searcher.search() to force a reload, but this doesn't seem to always work.
For instance, I'll delete an item through the Swift iOS API call and see the output below in the console after getting a response and then triggering searcher.search()
2020-12-29T12:54:30-0600 info com.algolia.InstantSearchCore : InstantSearch.SingleIndexSearcher: received results - index: LXIUfjLYsWgtRJGbdSsMluTr9GH3 query: "" hits count: 27 in 1ms
This is the correct count (there were 28 before the delete, so now there are 27), but when I return to the HitsTableViewController, the item I deleted is (sometimes, not always) still there. So I'm having trouble syncing the UI with the data available and creating predictive behavior. I don't want a user to see an item they just deleted. When I perform a blank search it usually gets rid of the old item and the display matches up with the data, but this is an additional unnecessary step I don't want a user to have to do. Not to mention it uses up two operations to do what one should do.
I found this post and also this that asks a similar question (granted it's for a much older version of the library), and @spinach suggests that forcing a reload is necessary. He also mentions registering with Instant Search, and I was wondering how that's done in the current version.
I tried something like this, and it only worked on my newer device:
My question: is searcher.search() the best way to do this? For me, it seems to work sometimes, but other times does not. It depends on the device I'm using. On older devices, it's not very reliable. Are there any methods I'm not utilizing that I should be?
My theory is that reloadData() is being called before the data is actually available or faster than the device can process it, hence why on my new iPhone everything works as expected, but on my 5 year old iPad, it doesn't.
RESOLVED: Wow, I didn't search very well. @VladislavFitz answered this exact problem yesterday here. All is well. Something like the code below works great and solves the race condition for the older device.
What is the best way to update HitsTableViewController after an add/delete/edit? Say that I have an index of items, and one of them is deleted from Algolia. I can use searcher.search() to force a reload, but this doesn't seem to always work.
For instance, I'll delete an item through the Swift iOS API call and see the output below in the console after getting a response and then triggering searcher.search()
2020-12-29T12:54:30-0600 info com.algolia.InstantSearchCore : InstantSearch.SingleIndexSearcher: received results - index: LXIUfjLYsWgtRJGbdSsMluTr9GH3 query: "" hits count: 27 in 1ms
This is the correct count (there were 28 before the delete, so now there are 27), but when I return to the HitsTableViewController, the item I deleted is (sometimes, not always) still there. So I'm having trouble syncing the UI with the data available and creating predictive behavior. I don't want a user to see an item they just deleted. When I perform a blank search it usually gets rid of the old item and the display matches up with the data, but this is an additional unnecessary step I don't want a user to have to do. Not to mention it uses up two operations to do what one should do.
I found this post and also this that asks a similar question (granted it's for a much older version of the library), and @spinach suggests that forcing a reload is necessary. He also mentions registering with Instant Search, and I was wondering how that's done in the current version.
I tried something like this, and it only worked on my newer device:
My question: is searcher.search() the best way to do this? For me, it seems to work sometimes, but other times does not. It depends on the device I'm using. On older devices, it's not very reliable. Are there any methods I'm not utilizing that I should be?
My theory is that reloadData() is being called before the data is actually available or faster than the device can process it, hence why on my new iPhone everything works as expected, but on my 5 year old iPad, it doesn't.
RESOLVED: Wow, I didn't search very well. @VladislavFitz answered this exact problem yesterday here. All is well. Something like the code below works great and solves the race condition for the older device.
The text was updated successfully, but these errors were encountered: