For hash map object:
messages = {
3: {
id: 3,
user_id: 1,
text: "My message"
},
345: {
id:345,
user_id: 2,
text: "Hello There!"
},
...
}
And in template I'm trying to add different styles if next and previous messages have different senders (user_id). Since this is not an array, I can't do:
messages[index + 1] or messages[index - 1]
I would need exact ID of next and/or previous message. I could take ineffiecient solution by converting messages object into array, finding index of current message ID and comparing ids of next and previous message senders. But it feels like there is better solution, specificaly because vue v-for already has "index" exposed.
Is there better approach to this problem? Assuming I'm not creating aditinal variables that track ids (this just increases complexity).