It could be useful to let the user pass the last read message, e.g.
ChatView(messages: messages, lastRead: lastReadMessage) { draft in
yourViewModel.send(draft: draft)
}
Where lastRead has type Message? and a default value of nil.
This could then show a view above or below that particular message, telling the user everything since then is unread.
I had a brief look at how I could implement it. Here's what I am thinking:
- Introduce an enum
Row that contains MessageRow and a new LastReadRow
- Modify
MessageSection's rows to be of type [Row]
- Modify
WrappingMessages to return this new Row instead of MessageRow
- Modify
UIList's tableView(_:cellForRowAt:) to take a Row and return a ChatMessageView or ChatLastReadView as appropriate
I think this refactoring could also be useful to allow other non-message cells in the future, such as status messages, which are not really messages but could still be shown in their own cells.
I'd be happy to work on this if you think it would be useful. Let me know what you think!
It could be useful to let the user pass the last read message, e.g.
Where
lastReadhas typeMessage?and a default value ofnil.This could then show a view above or below that particular message, telling the user everything since then is unread.
I had a brief look at how I could implement it. Here's what I am thinking:
Rowthat containsMessageRowand a newLastReadRowMessageSection'srowsto be of type[Row]WrappingMessagesto return this newRowinstead ofMessageRowUIList'stableView(_:cellForRowAt:)to take aRowand return aChatMessageVieworChatLastReadViewas appropriateI think this refactoring could also be useful to allow other non-message cells in the future, such as status messages, which are not really messages but could still be shown in their own cells.
I'd be happy to work on this if you think it would be useful. Let me know what you think!