Skip to content

Commit

Permalink
Bug 843066 - [SMS] Callback in 'appendThreads' is not working properl…
Browse files Browse the repository at this point in the history
…y r=julienw
  • Loading branch information
borjasalguero committed Feb 20, 2013
1 parent 1b6d7b1 commit e045526
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions apps/sms/js/sms.js
Expand Up @@ -547,7 +547,8 @@ var ThreadListUI = {
window.location.hash = '#thread-list';
},

renderThreads: function thlui_renderThreads(threads, callback) {
renderThreads:
function thlui_renderThreads(threads, threadsRenderedCallback) {
ThreadListUI.view.innerHTML = '';

if (threads.length > 0) {
Expand Down Expand Up @@ -578,6 +579,10 @@ var ThreadListUI = {
appendThreads(threads, function at_callback() {
// Boot update of headers
Utils.updateTimeHeaders();
// Once the rendering it's done, callback if needed
if (threadsRenderedCallback) {
threadsRenderedCallback();
}
});

} else {
Expand All @@ -590,11 +595,12 @@ var ThreadListUI = {
'</div>';
ThreadListUI.view.innerHTML = noResultHTML;
ThreadListUI.iconEdit.classList.add('disabled');
}

// Callback when every thread is appended
if (callback) {
callback();
// Callback if exist
if (threadsRenderedCallback) {
setTimeout(function executeCB() {
threadsRenderedCallback();
});
}
}
},

Expand Down Expand Up @@ -1165,7 +1171,7 @@ var ThreadUI = {
ThreadUI.scrollViewToBottom();
},
// Method for rendering the list of messages using infinite scroll
renderMessages: function thui_renderMessages(filter) {
renderMessages: function thui_renderMessages(filter, callback) {
// We initialize all params before rendering
this.initializeRendering();
// We call getMessages with callbacks
Expand All @@ -1176,6 +1182,9 @@ var ThreadUI = {
}
// Update STATUS of messages if needed
filter.read = false;
if (callback) {
callback();
}
setTimeout(function updatingStatus() {
var messagesUnreadIDs = [];
var changeStatusOptions = {
Expand Down

0 comments on commit e045526

Please sign in to comment.