mirror of https://github.com/moparisthebest/mail
always load visible bodies on successful sync
This commit is contained in:
parent
431ae8cd89
commit
4d2f56b20b
|
@ -24,8 +24,6 @@ define(function(require) {
|
||||||
$scope.synchronize(function() {
|
$scope.synchronize(function() {
|
||||||
// show notification
|
// show notification
|
||||||
notificationForEmail(email);
|
notificationForEmail(email);
|
||||||
// get message body
|
|
||||||
$scope.getBody($scope.filteredMessages[0]);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
chrome.notifications.onClicked.addListener(notificationClicked);
|
chrome.notifications.onClicked.addListener(notificationClicked);
|
||||||
|
@ -135,6 +133,9 @@ define(function(require) {
|
||||||
updateStatus('Last update: ', new Date());
|
updateStatus('Last update: ', new Date());
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
||||||
|
// fetch visible bodies at the end of a successful sync
|
||||||
|
$scope.loadVisibleBodies();
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
@ -397,22 +398,10 @@ define(function(require) {
|
||||||
var model = attrs.ngIscroll,
|
var model = attrs.ngIscroll,
|
||||||
listEl = elm[0];
|
listEl = elm[0];
|
||||||
|
|
||||||
scope.$watch(model, function() {
|
|
||||||
var myScroll;
|
|
||||||
// activate iscroll
|
|
||||||
myScroll = new IScroll(listEl, {
|
|
||||||
mouseWheel: true
|
|
||||||
});
|
|
||||||
|
|
||||||
// load the visible message bodies, when the list is re-initialized and when scrolling stopped
|
|
||||||
loadVisible();
|
|
||||||
myScroll.on('scrollEnd', loadVisible);
|
|
||||||
}, true);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* iterates over the mails in the mail list and loads their bodies if they are visible in the viewport
|
* iterates over the mails in the mail list and loads their bodies if they are visible in the viewport
|
||||||
*/
|
*/
|
||||||
function loadVisible() {
|
scope.loadVisibleBodies = function() {
|
||||||
var listBorder = listEl.getBoundingClientRect(),
|
var listBorder = listEl.getBoundingClientRect(),
|
||||||
top = listBorder.top,
|
top = listBorder.top,
|
||||||
bottom = listBorder.bottom,
|
bottom = listBorder.bottom,
|
||||||
|
@ -435,7 +424,20 @@ define(function(require) {
|
||||||
scope.getBody(message);
|
scope.getBody(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// re-init iScroll when model length changes
|
||||||
|
scope.$watch(model, function() {
|
||||||
|
var myScroll;
|
||||||
|
// activate iscroll
|
||||||
|
myScroll = new IScroll(listEl, {
|
||||||
|
mouseWheel: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// load the visible message bodies, when the list is re-initialized and when scrolling stopped
|
||||||
|
scope.loadVisibleBodies();
|
||||||
|
myScroll.on('scrollEnd', scope.loadVisibleBodies);
|
||||||
|
}, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -82,6 +82,8 @@ define(function(require) {
|
||||||
toggle: function() {}
|
toggle: function() {}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scope.loadVisibleBodies = function() {};
|
||||||
ctrl = $controller(MailListCtrl, {
|
ctrl = $controller(MailListCtrl, {
|
||||||
$scope: scope
|
$scope: scope
|
||||||
});
|
});
|
||||||
|
@ -148,13 +150,9 @@ define(function(require) {
|
||||||
expect(opts.type).to.equal('basic');
|
expect(opts.type).to.equal('basic');
|
||||||
expect(opts.message).to.equal('asdasd');
|
expect(opts.message).to.equal('asdasd');
|
||||||
expect(opts.title).to.equal('asd');
|
expect(opts.title).to.equal('asd');
|
||||||
};
|
|
||||||
|
|
||||||
scope.getBody = function() {
|
|
||||||
done();
|
done();
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.filteredMessages = [{}];
|
|
||||||
emailDaoMock.onIncomingMessage(mail);
|
emailDaoMock.onIncomingMessage(mail);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue