Find more efficient way to store messages on matches from tinder updates
state.matches[<match-id>]
in the TinderMatchStore
contains an object that describes a match (referred to as matchInfo
from hereon).
At present, matchInfo
contains a messages in the form of an array, but when updates are retrieved from tinder, it is hard to update that array with the latest message without going through the array to ensure we're not appending a duplicate. Few approaches could work:
- Change matches to an object, keyed by message ID, whenever the messages need to be in list form use
_.values()
and do necessary sorting - Write a small function to start from the end of the list and look for duplicates (this function can exit early if a message time is before the message we're trying to insert, as they're at least guaranteed to be in time-received order)