mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
The streams:all advertisement notice in search should only appear after all results have been fetched to indicate we've gotten to the beginning of the target feed. The notice gets hidden at the start of `narrow.activate` and is shown just after we've fetched an older batch of messages if the "oldest" message has been found. Previously it would get displayed after the first fetch which takes place from `narrow.activate`. Thus we move this logic to `notifications.hide_or_show_history_limit_message` which gets called after a successful message fetch. Since the home message view contains all the messages we are not required to display this notice. However if it is already shown we hide it as a part of `handle_post_narrow_deactivate_processes`. To accomplish this we need to add `has_found_oldest` key to the `fetch_status` API. We also removed the `pre_scroll_cont` parameter as this was it's only use case and is now redundant.
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
const FetchStatus = function () {
|
|
|
|
const self = {};
|
|
|
|
let loading_older = false;
|
|
let loading_newer = false;
|
|
let found_oldest = false;
|
|
let found_newest = false;
|
|
let history_limited = false;
|
|
|
|
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.has_found_oldest = function () {
|
|
return 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;
|
|
|
|
};
|
|
module.exports = FetchStatus;
|
|
window.FetchStatus = FetchStatus;
|