Merge lp:~phablet-team/messaging-app/mark_threads_as_read into lp:messaging-app/staging

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Tiago Salem Herrmann
Approved revision: 652
Merged at revision: 657
Proposed branch: lp:~phablet-team/messaging-app/mark_threads_as_read
Merge into: lp:messaging-app/staging
Prerequisite: lp:~phablet-team/messaging-app/disable_contact_matching_dinamically
Diff against target: 149 lines (+18/-32)
4 files modified
src/qml/Messages.qml (+10/-19)
src/qml/RegularMessageDelegate.qml (+0/-5)
src/qml/RegularMessageDelegate_irc.qml (+0/-6)
tests/qml/tst_MessagesView.qml (+8/-2)
To merge this branch: bzr merge lp:~phablet-team/messaging-app/mark_threads_as_read
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+316570@code.launchpad.net

Commit message

Mark entire threads as read when opening a channel

Description of the change

Mark entire threads as read when opening a channel

To post a comment you must log in.
642. By Tiago Salem Herrmann

also acknowledge messages to remove them from the indicator

643. By Tiago Salem Herrmann

merge parent branch

644. By Tiago Salem Herrmann

merge parent branch

645. By Tiago Salem Herrmann

merge parent branch

646. By Renato Araujo Oliveira Filho

Parent merged.

647. By Tiago Salem Herrmann

merge parent branch

648. By Gustavo Pichorim Boiko

Adapt to the model API change.

649. By Gustavo Pichorim Boiko

Change messaging-app to only acknowledge entire threads and not individual messages anymore.

650. By Gustavo Pichorim Boiko

Remove debug leftover

651. By Gustavo Pichorim Boiko

Adapt the test to the new approach of acknowledging messages

652. By Tiago Salem Herrmann

merge parent branch

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good!

review: Approve
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

looks good to me too.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/qml/Messages.qml'
2--- src/qml/Messages.qml 2017-03-08 22:08:10 +0000
3+++ src/qml/Messages.qml 2017-03-08 22:08:11 +0000
4@@ -83,7 +83,6 @@
5 property string scrollToEventId: ""
6 property bool isSearching: scrollToEventId !== ""
7 property string latestEventId: ""
8- property var pendingEventsToMarkAsRead: []
9 property bool reloadFilters: false
10 // to be used by tests as variant does not work with autopilot
11 property bool userTyping: false
12@@ -514,24 +513,14 @@
13 return Qt.createQmlObject(componentUnion.arg(componentFilters), eventModel)
14 }
15
16- function markMessageAsRead(accountId, threadId, eventId, type) {
17- var pendingEvent = {"accountId": accountId, "threadId": threadId, "messageId": eventId, "type": type, "chatType": messages.chatType, 'participantIds': messages.participantIds}
18- if (!mainView.applicationActive || !messages.active) {
19- pendingEventsToMarkAsRead.push(pendingEvent)
20- return false
21+ function markThreadAsRead() {
22+ if (!mainView.applicationActive || !messages.active || !messages.threads || messages.threads.length == 0) {
23+ return
24 }
25- chatManager.acknowledgeMessage(pendingEvent)
26- return eventModel.markEventAsRead(accountId, threadId, eventId, type);
27- }
28
29- function processPendingEvents() {
30- if (mainView.applicationActive && messages.active) {
31- for (var i in pendingEventsToMarkAsRead) {
32- var event = pendingEventsToMarkAsRead[i]
33- markMessageAsRead(event.accountId, event.threadId, event.messageId, event.type)
34- }
35- pendingEventsToMarkAsRead = []
36- }
37+ threadsModel.markThreadsAsRead(messages.threads);
38+ var properties = {'accountId': threads[0].accountId, 'threadId': threads[0].threadId, 'chatType': threads[0].chatType}
39+ chatManager.acknowledgeAllMessages(properties)
40 }
41
42 function selectActiveThread(threads) {
43@@ -884,6 +873,7 @@
44 // if we add multiple attachments at the same time, it break the Repeater + Loaders
45 fillAttachmentsTimer.start()
46 mainView.updateNewMessageStatus()
47+ markThreadAsRead()
48 }
49
50 Component.onDestruction: {
51@@ -924,7 +914,7 @@
52 if (!isReady) {
53 messages.ready()
54 }
55- processPendingEvents()
56+ markThreadAsRead()
57 if (!newMessage)
58 composeBar.forceFocus()
59 }
60@@ -1038,7 +1028,7 @@
61 }
62
63 onApplicationActiveChanged: {
64- processPendingEvents()
65+ markThreadAsRead()
66 }
67 }
68
69@@ -1303,6 +1293,7 @@
70 sortOrder: HistorySort.DescendingOrder
71 }
72 onCountChanged: {
73+ markThreadAsRead()
74 if (isSearching) {
75 // if we ask for more items manually listview will stop working,
76 // so we only set again once the item was found
77
78=== modified file 'src/qml/RegularMessageDelegate.qml'
79--- src/qml/RegularMessageDelegate.qml 2017-03-08 22:08:10 +0000
80+++ src/qml/RegularMessageDelegate.qml 2017-03-08 22:08:11 +0000
81@@ -98,10 +98,5 @@
82 root.startSelection()
83 root.selectItem(delegateItem)
84 }
85- Component.onCompleted: {
86- if (newEvent) {
87- messages.markMessageAsRead(accountId, threadId, eventId, type);
88- }
89- }
90 }
91 }
92
93=== modified file 'src/qml/RegularMessageDelegate_irc.qml'
94--- src/qml/RegularMessageDelegate_irc.qml 2017-03-08 22:08:10 +0000
95+++ src/qml/RegularMessageDelegate_irc.qml 2017-03-08 22:08:11 +0000
96@@ -197,10 +197,4 @@
97 }
98 ]
99 }
100-
101- Component.onCompleted: {
102- if (messageData.newEvent) {
103- messages.markMessageAsRead(messageData.accountId, threadId, eventId, type);
104- }
105- }
106 }
107
108=== modified file 'tests/qml/tst_MessagesView.qml'
109--- tests/qml/tst_MessagesView.qml 2017-03-08 22:08:10 +0000
110+++ tests/qml/tst_MessagesView.qml 2017-03-08 22:08:11 +0000
111@@ -138,15 +138,20 @@
112 Item {
113 id: chatManager
114 signal messageAcknowledged
115+ signal allMessagesAcknowledged(var properties)
116 function acknowledgeMessage(recipients, messageId, accountId) {
117 chatManager.messageAcknowledged(recipients, messageId, accountId)
118 }
119+
120+ function acknowledgeAllMessages(properties) {
121+ chatManager.allMessagesAcknowledged(properties)
122+ }
123 }
124
125 SignalSpy {
126 id: messageAcknowledgeSpy
127 target: chatManager
128- signalName: "messageAcknowledged"
129+ signalName: "allMessagesAcknowledged"
130 }
131
132 Item {
133@@ -198,6 +203,7 @@
134 function test_messagesViewAcknowledgeMessage() {
135 var senderId = "1234567"
136 messagesView.participantIds = [senderId]
137+ messagesView.threads = [ {threadId: "theThreadId"} ]
138 var messageList
139 while (true) {
140 messageList = findChild(messagesView, "messageList")
141@@ -211,7 +217,7 @@
142 tryCompare(messageList, 'count', 2)
143 compare(messageAcknowledgeSpy.count, 0)
144 mainView.applicationActive = true
145- tryCompare(messageAcknowledgeSpy, 'count', 2)
146+ tryCompare(messageAcknowledgeSpy, 'count', 1)
147 }
148 }
149 }

Subscribers

People subscribed via source and target branches

to all changes: