I’m rebuilding my apps favourites (likes) system. It was previously working great but used lists, so is not so future proof. Now it simply uses a favourites table with a “user” and “song” field and creates a new entry for each like. If the record already exists it removes it.
I have found 3 methods of showing the conditional heart icons in the RG cells, and would like to know which method is best to use.
Method 1
Each cell in the repeating group has a database search on it that looks for the parent groups song within the favourites table.
Pros: future proof.
Cons: 18 searches for every page load. Wu costs etc.
Graphically a little slow. Hearts are drawn noticeably after the main RG is shown.
Method 2
On page load, all of the users favourites are stored into a state. The RG cells then compare against this state (rather than searching the database per cell).
Pros: fastest UX
Only one initial search needs to be performed throughout users entire session.
Cons: Less future proof, as the entire favourites list must be stored in the state, which could become slow as the list grows too large. (However, we don’t mind limiting the maximum number of favourites, as that has a couple of upsides for our app.)
Method 3
On page load, only the user’s favourites that correspond to the current page of the repeating group are stored in a state. The RG cells then compare their songs against this smaller subset.
Pros: future proof.
Only the relevent data for the RG page is stored.
Only 1 search required per RG page or refresh, not every cell.
Cons: slowest. RG has to load first before it’s page items can be read giving noticeable visual delay.
The search is more complex, having to do “is in” checks.
Search has to be re-performed every time the RG page or data changes.
Which method would the bubble experts here use? Or are there any even better solutions I’ve not considered?
Ideally I would like to use method 1 combined with a temporary state for instant visual feedback…but this depends on how well optimised bubbles searches are when used like this. Does anyone know if bubble would actually charge me for 18 completely individual searches per page/RG refresh, or would it be able to cache & optimise behind the scenes to make this a low cost operation overall? I tried to figure out wu costs by looking into the log but couldn’t get clear answer.
Please also keep in that I may eventually want to offload this job to supabase so making it ‘migration friendly’ is also a consideration.
Thank you