mirror of
https://github.com/discourse/discourse.git
synced 2026-08-18 00:44:59 -05:00
As per https://github.com/discourse/discourse/commit/92839dc722057fcd8dcc2504bb89598423392744 lastMessage won't be null when a message is deleted. This would cause sorting issues when messages from a direct message channels are deleted as we would try to sort on last message and thought it would exist when actually it would be a null message. I might rethink this design to not return any last_message in this case soon as checking on ID feels dirty and prone to error, so only fixing the issue for now. This commit is also using `@cached` to avoid replaying the sort logic on each access.