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
=== modified file 'src/qml/Messages.qml'
--- src/qml/Messages.qml 2015-12-08 19:48:48 +0000
+++ src/qml/Messages.qml 2015-12-08 19:48:48 +0000
@@ -181,6 +181,46 @@
181 return (!tmpAccount || tmpAccount.type == AccountEntry.PhoneAccount || tmpAccount.type == AccountEntry.MultimediaAccount)181 return (!tmpAccount || tmpAccount.type == AccountEntry.PhoneAccount || tmpAccount.type == AccountEntry.MultimediaAccount)
182 }182 }
183183
184 function addNewThreadToFilter(newAccountId, participantIds) {
185 var newAccount = telepathyHelper.accountForId(newAccountId)
186 var matchType = HistoryThreadModel.MatchCaseSensitive
187 if (newAccount.type == AccountEntry.PhoneAccount || newAccount.type == AccountEntry.MultimediaAccount) {
188 matchType = HistoryThreadModel.MatchPhoneNumber
189 }
190
191 var thread = eventModel.threadForParticipants(newAccountId,
192 HistoryThreadModel.EventTypeText,
193 participantIds,
194 matchType,
195 true)
196 var threadId = thread.threadId
197
198 // dont change the participants list
199 if (messages.participants.length == 0) {
200 messages.participants = thread.participants
201 var ids = []
202 for (var i in messages.participants) {
203 ids.push(messages.participants[i].identifier)
204 }
205 messages.participantIds = ids;
206 }
207
208 var found = false;
209 for (var i in messages.threads) {
210 if (messages.threads[i].threadId == threadId && messages.threads[i].accountId == newAccountId) {
211 found = true;
212 break;
213 }
214 }
215
216 if (!found) {
217 messages.threads.push({"accountId": newAccountId, "threadId": threadId})
218 reloadFilters = !reloadFilters
219 }
220
221 return thread
222 }
223
184 Connections {224 Connections {
185 target: telepathyHelper225 target: telepathyHelper
186 onSetupReady: {226 onSetupReady: {
@@ -316,35 +356,8 @@
316 }356 }
317357
318 // create the new thread and update the threadId list358 // create the new thread and update the threadId list
319 var thread = eventModel.threadForParticipants(messages.account.accountId,359 var thread = addNewThreadToFilter(messages.account.accountId, participantIds)
320 HistoryThreadModel.EventTypeText,360
321 participantIds,
322 messages.account.type == AccountEntry.PhoneAccount ? HistoryThreadModel.MatchPhoneNumber
323 : HistoryThreadModel.MatchCaseSensitive,
324 true)
325 var threadId = thread.threadId
326
327 // dont change the participants list
328 if (messages.participants.length == 0) {
329 messages.participants = thread.participants
330 var ids = []
331 for (var i in messages.participants) {
332 ids.push(messages.participants[i].identifier)
333 }
334 messages.participantIds = ids;
335 }
336
337 var found = false;
338 for (var i in messages.threads) {
339 if (messages.threads[i].threadId == threadId && messages.threads[i].accountId == messages.account.accountId) {
340 found = true;
341 break;
342 }
343 }
344 if (!found) {
345 messages.threads.push({"accountId": messages.account.accountId, "threadId": threadId})
346 reloadFilters = !reloadFilters
347 }
348 for (var i=0; i < eventModel.count; i++) {361 for (var i=0; i < eventModel.count; i++) {
349 var event = eventModel.get(i)362 var event = eventModel.get(i)
350 if (event.senderId == "self" && event.accountId != messages.account.accountId) {363 if (event.senderId == "self" && event.accountId != messages.account.accountId) {
@@ -357,7 +370,7 @@
357 // if the last outgoing message used a different accountId, add an370 // if the last outgoing message used a different accountId, add an
358 // information event and quit the loop371 // information event and quit the loop
359 eventModel.writeTextInformationEvent(messages.account.accountId,372 eventModel.writeTextInformationEvent(messages.account.accountId,
360 threadId,373 thread.threadId,
361 participantIds,374 participantIds,
362 "")375 "")
363 break;376 break;
@@ -375,7 +388,7 @@
375 var timestamp = new Date()388 var timestamp = new Date()
376 var tmpEventId = timestamp.toISOString()389 var tmpEventId = timestamp.toISOString()
377 event["accountId"] = messages.account.accountId390 event["accountId"] = messages.account.accountId
378 event["threadId"] = threadId391 event["threadId"] = thread.threadId
379 event["eventId"] = tmpEventId392 event["eventId"] = tmpEventId
380 event["type"] = HistoryEventModel.MessageTypeText393 event["type"] = HistoryEventModel.MessageTypeText
381 event["participants"] = thread.participants394 event["participants"] = thread.participants
@@ -393,7 +406,7 @@
393 var attachment = {}406 var attachment = {}
394 var item = attachments[i]407 var item = attachments[i]
395 attachment["accountId"] = messages.account.accountId408 attachment["accountId"] = messages.account.accountId
396 attachment["threadId"] = threadId409 attachment["threadId"] = thread.threadId
397 attachment["eventId"] = tmpEventId410 attachment["eventId"] = tmpEventId
398 attachment["attachmentId"] = item[0]411 attachment["attachmentId"] = item[0]
399 attachment["contentType"] = item[1]412 attachment["contentType"] = item[1]
@@ -413,9 +426,13 @@
413 if (isMmsGroupChat && !isSelfContactKnown) {426 if (isMmsGroupChat && !isSelfContactKnown) {
414 // TODO: inform the user to enter the phone number of the selected sim card manually427 // TODO: inform the user to enter the phone number of the selected sim card manually
415 // and use it in the telepathy-ofono account as selfContactId. 428 // and use it in the telepathy-ofono account as selfContactId.
416 return429 return false
417 }430 }
418 chatManager.sendMessage(messages.account.accountId, participantIds, text, attachments, properties)431 var fallbackAccountId = chatManager.sendMessage(messages.account.accountId, participantIds, text, attachments, properties)
432 // create the new thread and update the threadId list
433 if (fallbackAccountId != messages.account.accountId) {
434 addNewThreadToFilter(fallbackAccountId, participantIds)
435 }
419 }436 }
420437
421 // FIXME: soon it won't be just about SIM cards, so the dialogs need updating438 // FIXME: soon it won't be just about SIM cards, so the dialogs need updating

Subscribers

People subscribed via source and target branches