Files
zulip/static/js/fetch_status.js
Tim Abbott ce187b0899 message_fetch: Deduplicate logic for start_newer_batch.
Like the other commits in this series, we were already doing this in
all of the callers of load_messages; this centralizes that logic in a
less ad-hoc feeling way.

We no longer use or need the start_initial_narrow function.
2018-12-13 08:43:56 -08:00

58 lines
1.3 KiB
JavaScript

var FetchStatus = function () {
var self = {};
var loading_older = false;
var loading_newer = false;
var found_oldest = false;
var found_newest = false;
var history_limited = false;
self.finish_initial_narrow = function (opts) {
loading_newer = false;
found_newest = opts.found_newest;
};
self.start_older_batch = function () {
loading_older = true;
};
self.finish_older_batch = function (opts) {
loading_older = false;
found_oldest = opts.found_oldest;
history_limited = opts.history_limited;
};
self.can_load_older_messages = function () {
return !loading_older && !found_oldest;
};
self.history_limited = function () {
return history_limited;
};
self.start_newer_batch = function () {
loading_newer = true;
};
self.finish_newer_batch = function (opts) {
loading_newer = false;
found_newest = opts.found_newest;
};
self.can_load_newer_messages = function () {
return !loading_newer && !found_newest;
};
self.has_found_newest = function () {
return found_newest;
};
return self;
};
if (typeof module !== 'undefined') {
module.exports = FetchStatus;
}
window.FetchStatus = FetchStatus;