- if(!dayChangeItem && idx < _messageList.count() && _messageList[idx]->msgType() != Message::DayChange) {
- QDateTime nextTs = _messageList[idx]->timeStamp();
+ if(!dayChangeItem && start < _messageList.count()) {
+ // check if we need to insert a daychange message at the end of the this group
+
+ // if this assert triggers then indexForId() would have found a spot right before a DayChangeMsg
+ // this should never happen as daychange messages share the msgId with the preceeding message
+ Q_ASSERT(_messageList[start]->msgType() != Message::DayChange);
+ QDateTime nextTs = _messageList[start]->timeStamp();