Sort Cached Messages
ClosedPublic

Authored by sredman on Aug 28 2018, 2:45 AM.

Details

Summary

Previously, incoming messages were appened to a QList. This list was accidentally sorted because that's how Android returned them, but new messages were appended to the wrong end of the list. This patch specifically and intentionally sorts messages so new ones become visible

Test Plan
  • Open SMS GUI, verify that the most-recent messages are shown
  • Either send or recieve an SMS
  • Wait about 5s (I do not know why this is necessary. Probably some Android weirdness)
  • De-select the current conversation, then re-select it
    • TODO: Make the app automatically respond to new messages
  • The newly sent or recieved message should be shown in the most-recent position

Diff Detail

Repository
R224 KDE Connect
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sredman created this revision.Aug 28 2018, 2:45 AM
Restricted Application added a project: KDE Connect. · View Herald TranscriptAug 28 2018, 2:45 AM
Restricted Application added a subscriber: kdeconnect. · View Herald Transcript
sredman requested review of this revision.Aug 28 2018, 2:45 AM

Is it really necessary? We use a ProxyModel to sort the messages in the view

Is it really necessary? We use a ProxyModel to sort the messages in the view

Yes because in the app we ask the ConversationDBusInterface for the 10 most recent messages. Since the list was badly sorted it would return the 10 most recent messages at the time they were requested. If new messages came in, they would not be shown (you made a reference to this earlier as having to disconnect and reconnect to see new messages). They would be correctly sorted in the QML app, but the app was already receiving stale data. This makes the situation a little better in that you only have to change which conversation is being viewed to see new messages.

I think the method of getting messages into the app might need to be redesigned at some point regardless, but I expect we will want a sorted representation in the model no matter what

I have drawn what was happening before: Hopefully that helps show why this is a needed change:

apol added a subscriber: apol.Aug 28 2018, 4:29 PM
apol added inline comments.
plugins/telephony/conversationsdbusinterface.cpp
71

i >= end

plugins/telephony/conversationsdbusinterface.h
86

I wouldn't call it a list if it's not a list.
Also would it make sense to have the timestamp in ConversationMessage?

sredman updated this revision to Diff 40651.Aug 29 2018, 2:47 PM
  • Clairify comment about structure of m_conversations
  • Use >= instead of !<
sredman marked 2 inline comments as done.Aug 29 2018, 2:48 PM
sredman added inline comments.
plugins/telephony/conversationsdbusinterface.h
86

The timestamp is a field of ConversationMessage already. It feels kind of dumb to store it twice like this, but it is very easy to do it this way...

apol accepted this revision.Sep 8 2018, 4:16 PM
This revision is now accepted and ready to land.Sep 8 2018, 4:16 PM
This revision was automatically updated to reflect the committed changes.
sredman marked an inline comment as done.