Merge lp:~tiagosh/messaging-app/add-fallback-account-to-filter into lp:messaging-app

Proposed by Tiago Salem Herrmann
Status: Merged
Merged at revision: 497
Proposed branch: lp:~tiagosh/messaging-app/add-fallback-account-to-filter
Merge into: lp:messaging-app
Prerequisite: lp:~phablet-team/messaging-app/audio_recording_ui
Diff against target: 132 lines (+52/-35)
1 file modified
src/qml/Messages.qml (+52/-35)
To merge this branch: bzr merge lp:~tiagosh/messaging-app/add-fallback-account-to-filter
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+279890@code.launchpad.net

Commit message

Add fallback accountId to the history filter.

Description of the change

Add fallback accountId to the history filter.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
481. By Tiago Salem Herrmann

merge parent branch

482. By Tiago Salem Herrmann

merge parent branch

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

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-12-08 19:48:48 +0000
3+++ src/qml/Messages.qml 2015-12-08 19:48:48 +0000
4@@ -181,6 +181,46 @@
5 return (!tmpAccount || tmpAccount.type == AccountEntry.PhoneAccount || tmpAccount.type == AccountEntry.MultimediaAccount)
6 }
7
8+ function addNewThreadToFilter(newAccountId, participantIds) {
9+ var newAccount = telepathyHelper.accountForId(newAccountId)
10+ var matchType = HistoryThreadModel.MatchCaseSensitive
11+ if (newAccount.type == AccountEntry.PhoneAccount || newAccount.type == AccountEntry.MultimediaAccount) {
12+ matchType = HistoryThreadModel.MatchPhoneNumber
13+ }
14+
15+ var thread = eventModel.threadForParticipants(newAccountId,
16+ HistoryThreadModel.EventTypeText,
17+ participantIds,
18+ matchType,
19+ true)
20+ var threadId = thread.threadId
21+
22+ // dont change the participants list
23+ if (messages.participants.length == 0) {
24+ messages.participants = thread.participants
25+ var ids = []
26+ for (var i in messages.participants) {
27+ ids.push(messages.participants[i].identifier)
28+ }
29+ messages.participantIds = ids;
30+ }
31+
32+ var found = false;
33+ for (var i in messages.threads) {
34+ if (messages.threads[i].threadId == threadId && messages.threads[i].accountId == newAccountId) {
35+ found = true;
36+ break;
37+ }
38+ }
39+
40+ if (!found) {
41+ messages.threads.push({"accountId": newAccountId, "threadId": threadId})
42+ reloadFilters = !reloadFilters
43+ }
44+
45+ return thread
46+ }
47+
48 Connections {
49 target: telepathyHelper
50 onSetupReady: {
51@@ -316,35 +356,8 @@
52 }
53
54 // create the new thread and update the threadId list
55- var thread = eventModel.threadForParticipants(messages.account.accountId,
56- HistoryThreadModel.EventTypeText,
57- participantIds,
58- messages.account.type == AccountEntry.PhoneAccount ? HistoryThreadModel.MatchPhoneNumber
59- : HistoryThreadModel.MatchCaseSensitive,
60- true)
61- var threadId = thread.threadId
62-
63- // dont change the participants list
64- if (messages.participants.length == 0) {
65- messages.participants = thread.participants
66- var ids = []
67- for (var i in messages.participants) {
68- ids.push(messages.participants[i].identifier)
69- }
70- messages.participantIds = ids;
71- }
72-
73- var found = false;
74- for (var i in messages.threads) {
75- if (messages.threads[i].threadId == threadId && messages.threads[i].accountId == messages.account.accountId) {
76- found = true;
77- break;
78- }
79- }
80- if (!found) {
81- messages.threads.push({"accountId": messages.account.accountId, "threadId": threadId})
82- reloadFilters = !reloadFilters
83- }
84+ var thread = addNewThreadToFilter(messages.account.accountId, participantIds)
85+
86 for (var i=0; i < eventModel.count; i++) {
87 var event = eventModel.get(i)
88 if (event.senderId == "self" && event.accountId != messages.account.accountId) {
89@@ -357,7 +370,7 @@
90 // if the last outgoing message used a different accountId, add an
91 // information event and quit the loop
92 eventModel.writeTextInformationEvent(messages.account.accountId,
93- threadId,
94+ thread.threadId,
95 participantIds,
96 "")
97 break;
98@@ -375,7 +388,7 @@
99 var timestamp = new Date()
100 var tmpEventId = timestamp.toISOString()
101 event["accountId"] = messages.account.accountId
102- event["threadId"] = threadId
103+ event["threadId"] = thread.threadId
104 event["eventId"] = tmpEventId
105 event["type"] = HistoryEventModel.MessageTypeText
106 event["participants"] = thread.participants
107@@ -393,7 +406,7 @@
108 var attachment = {}
109 var item = attachments[i]
110 attachment["accountId"] = messages.account.accountId
111- attachment["threadId"] = threadId
112+ attachment["threadId"] = thread.threadId
113 attachment["eventId"] = tmpEventId
114 attachment["attachmentId"] = item[0]
115 attachment["contentType"] = item[1]
116@@ -413,9 +426,13 @@
117 if (isMmsGroupChat && !isSelfContactKnown) {
118 // TODO: inform the user to enter the phone number of the selected sim card manually
119 // and use it in the telepathy-ofono account as selfContactId.
120- return
121- }
122- chatManager.sendMessage(messages.account.accountId, participantIds, text, attachments, properties)
123+ return false
124+ }
125+ var fallbackAccountId = chatManager.sendMessage(messages.account.accountId, participantIds, text, attachments, properties)
126+ // create the new thread and update the threadId list
127+ if (fallbackAccountId != messages.account.accountId) {
128+ addNewThreadToFilter(fallbackAccountId, participantIds)
129+ }
130 }
131
132 // FIXME: soon it won't be just about SIM cards, so the dialogs need updating

Subscribers

People subscribed via source and target branches