Reply "Collision detection"
Since our Super Users asked for it I cobbled together this widget. It's not perfect, but it seems to be working.
I asked Lithium to add a custom field for messages, so I can save a state of who is currently replying to a post and when they hit reply.
Logic:
On loading the Reply Page, check if the user has a certain role, like Super User.
If yes:
- add the current user's id and system time to the list in that custom field.
- check that same field for other entries
- If an entry is found, check how long ago the other user(s) loaded the Reply page and if within a certain time frame, show the current user who else is replying.
Since I don't know how to cleanly hook into the reply (post) button's built-in triggers I added a mouseenter trigger to the Post and Cancel buttons, which removes the user's id and time from the custom field.
Screenshot below. Code is attached. One component, one endpoint.