Assigned Issue BAMB-130 : http://servlet.uwyn.com/issues/browse/BAMB-130
I have been thinking about this some more and I think that I might have found a solution that's foolproof.
You track which messages have been read by a user at which time. This allows you to indicate if a message is either:
- new (id not in the tracking table)
- updated (date time is later than the users read)
The problem with this is that you will end up with a message record for each message and user, this can become huge. Therefore you also keep track of the last read message that is part of a strictly continuous series.
For instance:
| messages |
read |
| msg8 |
|
| msg7 |
|
| msg6 |
x |
| msg5 |
x |
| msg4 |
|
| msg3 |
x |
| msg2 |
x |
| msg1 |
x |
Indicates that all messages from msg3 onwards have been read and shouldn't be stored anymore. So you end up storing:
| messages |
read |
lastread |
| msg8 |
|
|
| msg7 |
|
|
| msg6 |
x |
|
| msg5 |
x |
|
| msg4 |
|
|
| msg3 |
|
x |
| msg2 |
|
|
| msg1 |
|
|
This can also be used for a 'mark all messages as read' feature.
For the lastread storage you should also store the date when that read occurred, you can check that with the update time of messages that are read to see if they have been updated and correctly show the third state.
What do you think? I haven't really worked it out for all cases yet, maybe you can tackle that?
Jive stores it just all in a table: