Merge lp:~tiagosh/messaging-app/updateFilters-binding into lp:messaging-app

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 429
Merged at revision: 450
Proposed branch: lp:~tiagosh/messaging-app/updateFilters-binding
Merge into: lp:messaging-app
Diff against target: 109 lines (+13/-28)
1 file modified
src/qml/Messages.qml (+13/-28)
To merge this branch: bzr merge lp:~tiagosh/messaging-app/updateFilters-binding
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+269478@code.launchpad.net

Commit message

Turn updateFilters() into a binding.

Description of the change

Turn updateFilters() into a binding.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good and works as expected!

review: Approve
430. By Tiago Salem Herrmann

merge trunk

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 2015-09-21 19:56:31 +0000
3+++ src/qml/Messages.qml 2015-09-28 21:00:49 +0000
4@@ -47,12 +47,12 @@
5 property int activeAttachmentIndex: -1
6 property var sharedAttachmentsTransfer: []
7 property alias contactWatcher: contactWatcherInternal
8- property string lastFilter: ""
9 property string text: ""
10 property string scrollToEventId: ""
11 property bool isSearching: scrollToEventId !== ""
12 property string latestEventId: ""
13 property var pendingEventsToMarkAsRead: []
14+ property bool reloadFilters: false
15 // to be used by tests as variant does not work with autopilot
16 property string firstParticipant: participants.length > 0 ? participants[0] : ""
17
18@@ -213,11 +213,6 @@
19 onAccountChanged: messages.account = mainView.account
20 }
21
22- Connections {
23- target: telepathyHelper
24- onAccountsChanged: updateFilters()
25- }
26-
27 ActivityIndicator {
28 id: activityIndicator
29 anchors {
30@@ -277,7 +272,6 @@
31 }
32
33 Component.onCompleted: {
34- updateFilters()
35 addAttachmentsToModel(sharedAttachmentsTransfer)
36 }
37
38@@ -287,16 +281,15 @@
39 }
40 }
41
42- function updateFilters() {
43- if (participants.length == 0) {
44- eventModel.filter = null
45- return
46+ function updateFilters(accounts, participants, reload) {
47+ if (participants.length == 0 || accounts.length == 0) {
48+ return null
49 }
50
51 var componentUnion = "import Ubuntu.History 0.1; HistoryUnionFilter { %1 }"
52 var componentFilters = ""
53- for (var i in telepathyHelper.accounts) {
54- var account = telepathyHelper.accounts[i];
55+ for (var i in accounts) {
56+ var account = accounts[i];
57 var filterValue = eventModel.threadIdForParticipants(account.accountId,
58 HistoryThreadModel.EventTypeText,
59 participants,
60@@ -310,15 +303,9 @@
61 componentFilters += 'HistoryFilter { property string value: "%1"; filterProperty: "threadId"; filterValue: value } '.arg(filterValue)
62 }
63 if (componentFilters === "") {
64- eventModel.filter = null
65- lastFilter = ""
66- return
67- }
68- if (componentFilters != lastFilter) {
69- var finalString = componentUnion.arg(componentFilters)
70- eventModel.filter = Qt.createQmlObject(finalString, eventModel)
71- lastFilter = componentFilters
72- }
73+ return null
74+ }
75+ return Qt.createQmlObject(componentUnion.arg(componentFilters), eventModel)
76 }
77
78 function markMessageAsRead(accountId, threadId, eventId, type) {
79@@ -522,10 +509,6 @@
80 addressableFields: messages.account ? messages.account.addressableVCardFields : ["tel"] // just to have a fallback there
81 }
82
83- onParticipantsChanged: {
84- updateFilters()
85- }
86-
87 Action {
88 id: backButton
89 objectName: "backButton"
90@@ -676,7 +659,7 @@
91 HistoryEventModel {
92 id: eventModel
93 type: HistoryThreadModel.EventTypeText
94- filter: null
95+ filter: updateFilters(telepathyHelper.accounts, messages.participants, messages.reloadFilters)
96 sort: HistorySort {
97 sortField: "timestamp"
98 sortOrder: HistorySort.DescendingOrder
99@@ -1080,7 +1063,9 @@
100 textEntry.text = ""
101 attachments.clear()
102 }
103- updateFilters()
104+ if (eventModel.filter == null) {
105+ reloadFilters = !reloadFilters
106+ }
107 }
108 }
109 }

Subscribers

People subscribed via source and target branches