2018-03-09 22:04:07 +01:00
|
|
|
var FetchStatus = function () {
|
|
|
|
|
|
|
|
var self = {};
|
|
|
|
|
|
|
|
var loading_older = false;
|
|
|
|
var loading_newer = false;
|
|
|
|
var found_oldest = false;
|
|
|
|
var found_newest = false;
|
2018-12-13 00:53:35 +01:00
|
|
|
var history_limited = false;
|
2018-03-09 22:04:07 +01:00
|
|
|
|
|
|
|
self.start_older_batch = function () {
|
|
|
|
loading_older = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
self.finish_older_batch = function (opts) {
|
|
|
|
loading_older = false;
|
|
|
|
found_oldest = opts.found_oldest;
|
2018-12-13 00:53:35 +01:00
|
|
|
history_limited = opts.history_limited;
|
2018-03-09 22:04:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
self.can_load_older_messages = function () {
|
|
|
|
return !loading_older && !found_oldest;
|
|
|
|
};
|
|
|
|
|
2018-12-13 00:53:35 +01:00
|
|
|
self.history_limited = function () {
|
|
|
|
return history_limited;
|
|
|
|
};
|
|
|
|
|
2018-03-09 22:04:07 +01:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2018-05-03 19:44:11 +02:00
|
|
|
self.has_found_newest = function () {
|
|
|
|
return found_newest;
|
|
|
|
};
|
|
|
|
|
2018-03-09 22:04:07 +01:00
|
|
|
return self;
|
|
|
|
|
|
|
|
};
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = FetchStatus;
|
|
|
|
}
|
2018-05-28 08:04:36 +02:00
|
|
|
window.FetchStatus = FetchStatus;
|