This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
Bug 936370 [Messaging] Scrolling issues and reduce unnecessary calls for updating UI. r=julienw #13512
Merged
borjasalguero
merged 1 commit into
mozilla-b2g:master
from
borjasalguero:bug_scrolling_issues
Nov 15, 2013
Merged
Bug 936370 [Messaging] Scrolling issues and reduce unnecessary calls for updating UI. r=julienw #13512
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,6 +238,11 @@ var ThreadUI = global.ThreadUI = { | |
'mousedown', this.requestContact.bind(this) | ||
); | ||
|
||
navigator.mozContacts.addEventListener( | ||
'contactchange', | ||
this.updateHeaderData | ||
); | ||
|
||
this.tmpl = templateIds.reduce(function(tmpls, name) { | ||
tmpls[Utils.camelCase(name)] = | ||
Template('messages-' + name + '-tmpl'); | ||
|
@@ -256,17 +261,6 @@ var ThreadUI = global.ThreadUI = { | |
this.INPUT_MARGIN = parseInt(style.getPropertyValue('margin-top'), 10) + | ||
parseInt(style.getPropertyValue('margin-bottom'), 10); | ||
|
||
// Synchronize changes to the Compose field according to relevant changes | ||
// in the subheader. | ||
var subheaderMutationHandler = this.subheaderMutationHandler.bind(this); | ||
var subheaderMutation = new MutationObserver(subheaderMutationHandler); | ||
subheaderMutation.observe(this.subheader, { | ||
attributes: true, subtree: true | ||
}); | ||
subheaderMutation.observe(document.getElementById('thread-messages'), { | ||
attributes: true | ||
}); | ||
|
||
ThreadUI.setInputMaxHeight(); | ||
}, | ||
|
||
|
@@ -528,13 +522,6 @@ var ThreadUI = global.ThreadUI = { | |
}.bind(this), this.CONVERTED_MESSAGE_DURATION); | ||
}, | ||
|
||
// Ensure that when the subheader is updated, the Compose field's dimensions | ||
// are updated to avoid interference. | ||
subheaderMutationHandler: function thui_subheaderMutationHandler() { | ||
this.setInputMaxHeight(); | ||
this.updateInputHeight(); | ||
}, | ||
|
||
// Triggered when the onscreen keyboard appears/disappears. | ||
resizeHandler: function thui_resizeHandler() { | ||
if (!this.inEditMode) { | ||
|
@@ -927,8 +914,6 @@ var ThreadUI = global.ThreadUI = { | |
// the container | ||
var buttonOffset = newHeight + verticalMargin - buttonHeight; | ||
this.sendButton.style.marginTop = buttonOffset + 'px'; | ||
|
||
this.scrollViewToBottom(); | ||
}, | ||
|
||
findNextContainer: function thui_findNextContainer(container) { | ||
|
@@ -1061,6 +1046,48 @@ var ThreadUI = global.ThreadUI = { | |
return messageContainer; | ||
}, | ||
|
||
updateCarrier: function thui_updateCarrier(thread, contacts, details) { | ||
var carrierTag = document.getElementById('contact-carrier'); | ||
var threadMessages = document.getElementById('thread-messages'); | ||
var number = thread.participants[0]; | ||
var wasCarrierTagShown = threadMessages.classList.contains('has-carrier'); | ||
var isCarrierTagShown = false; | ||
var carrierText; | ||
|
||
// The carrier banner is meaningless and confusing in | ||
// group message mode. | ||
if (thread.participants.length === 1 && | ||
(contacts && contacts.length)) { | ||
|
||
|
||
carrierText = Utils.getCarrierTag( | ||
number, contacts[0].tel, details | ||
); | ||
|
||
// Known Contact with at least: | ||
// | ||
// 1. a name | ||
// 2. a carrier | ||
// 3. a type | ||
// | ||
if (carrierText) { | ||
carrierTag.textContent = carrierText; | ||
isCarrierTagShown = true; | ||
threadMessages.classList.add('has-carrier'); | ||
} else { | ||
threadMessages.classList.remove('has-carrier'); | ||
} | ||
} else { | ||
// Hide carrier tag in group message or unknown contact cases. | ||
threadMessages.classList.remove('has-carrier'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
} | ||
|
||
if (wasCarrierTagShown !== isCarrierTagShown) { | ||
this.setInputMaxHeight(); | ||
this.updateInputHeight(); | ||
} | ||
}, | ||
|
||
// Method for updating the header with the info retrieved from Contacts API | ||
updateHeaderData: function thui_updateHeaderData(callback) { | ||
var thread, number, others; | ||
|
@@ -1105,48 +1132,18 @@ var ThreadUI = global.ThreadUI = { | |
// Jane Doe (+2) | ||
// | ||
Contacts.findByPhoneNumber(number, function gotContact(contacts) { | ||
var carrierTag = document.getElementById('contact-carrier'); | ||
var threadMessages = document.getElementById('thread-messages'); | ||
var details = Utils.getContactDetails(number, contacts); | ||
// Bug 867948: contacts null is a legitimate case, and | ||
// getContactDetails is okay with that. | ||
var details = Utils.getContactDetails(number, contacts); | ||
var contactName = details.title || number; | ||
var carrierText; | ||
|
||
this.headerText.dataset.isContact = !!details.isContact; | ||
this.headerText.dataset.title = contactName; | ||
navigator.mozL10n.localize(this.headerText, 'thread-header-text', { | ||
name: contactName, | ||
n: others | ||
}); | ||
|
||
// The carrier banner is meaningless and confusing in | ||
// group message mode. | ||
if (thread.participants.length === 1 && | ||
(contacts && contacts.length)) { | ||
|
||
|
||
carrierText = Utils.getCarrierTag( | ||
number, contacts[0].tel, details | ||
); | ||
|
||
// Known Contact with at least: | ||
// | ||
// 1. a name | ||
// 2. a carrier | ||
// 3. a type | ||
// | ||
|
||
if (carrierText) { | ||
carrierTag.textContent = carrierText; | ||
threadMessages.classList.add('has-carrier'); | ||
} else { | ||
threadMessages.classList.remove('has-carrier'); | ||
} | ||
} else { | ||
// Hide carrier tag in group message or unknown contact cases. | ||
threadMessages.classList.remove('has-carrier'); | ||
} | ||
this.updateCarrier(thread, contacts, details); | ||
|
||
if (callback) { | ||
callback(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the other call to
navigator.mozContacts.addEventListener
break desktop testing, but it's easy to fix: https://gist.github.com/rwaldron/7474280There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added! Thanks for the tip!