Closed adi518 closed 2 years ago
Would you also want to update the timestamp if any of the segments properties are changed, e.g., startTime
and endTime
. Another possibility could be to use the segments.add
, segments.remove
, segments.update
, segments.dragged
events.
Supposedly, you're right and it'd be prone to bugs otherwise. However, I just tested it with dragging some segments without adding or removing any and it still works as expected, so I guess the segments array still gets called with add/remove. Actually, how does Peaks maintain its array of segments? does it do it linearly?
They're just stored internally in an array in the order that you add them. Dragging a segment doesn't change it's position in the array.
Closing since it didn't really matter at the end of it. We manage a memoized and sorted source of truth which peaks reads from, so it's all good.
I have to memoize a sorted segments array. To do that efficiently, I need a clear indicator for when the array has updated, which means I need a
timestamp
field that gets updated each time a segment is added or removed to/from the array. I'd like to hear other ideas as well.Meanwhile, I hacked it like so:
And now I can do this: