mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 12:33:40 +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.
159 lines
3.0 KiB
JavaScript
159 lines
3.0 KiB
JavaScript
const FetchStatus = zrequire('fetch_status');
|
|
|
|
let fetch_status = FetchStatus();
|
|
|
|
function reset() {
|
|
fetch_status = FetchStatus();
|
|
}
|
|
|
|
function can_load_newer() {
|
|
assert.equal(fetch_status.can_load_newer_messages(), true);
|
|
}
|
|
|
|
function blocked_newer() {
|
|
assert.equal(fetch_status.can_load_newer_messages(), false);
|
|
}
|
|
|
|
function can_load_older() {
|
|
assert.equal(fetch_status.can_load_older_messages(), true);
|
|
}
|
|
|
|
function blocked_older() {
|
|
assert.equal(fetch_status.can_load_older_messages(), false);
|
|
}
|
|
|
|
function has_found_oldest() {
|
|
assert.equal(fetch_status.has_found_oldest(), true);
|
|
}
|
|
|
|
function has_not_found_oldest() {
|
|
assert.equal(fetch_status.has_found_oldest(), false);
|
|
}
|
|
|
|
function has_found_newest() {
|
|
assert.equal(fetch_status.has_found_newest(), true);
|
|
}
|
|
|
|
function has_not_found_newest() {
|
|
assert.equal(fetch_status.has_found_newest(), false);
|
|
}
|
|
|
|
function can_load_history() {
|
|
assert.equal(fetch_status.history_limited(), false);
|
|
}
|
|
|
|
function blocked_history() {
|
|
assert.equal(fetch_status.history_limited(), true);
|
|
}
|
|
|
|
run_test('basics', () => {
|
|
reset();
|
|
|
|
fetch_status.start_newer_batch();
|
|
fetch_status.start_older_batch();
|
|
|
|
blocked_newer();
|
|
blocked_older();
|
|
can_load_history();
|
|
has_not_found_oldest();
|
|
has_not_found_newest();
|
|
|
|
let data = {
|
|
found_oldest: true,
|
|
found_newest: true,
|
|
history_limited: true,
|
|
};
|
|
fetch_status.finish_newer_batch(data);
|
|
fetch_status.finish_older_batch(data);
|
|
|
|
has_found_oldest();
|
|
has_found_newest();
|
|
blocked_newer();
|
|
blocked_older();
|
|
blocked_history();
|
|
|
|
reset();
|
|
|
|
fetch_status.start_newer_batch();
|
|
fetch_status.start_older_batch();
|
|
|
|
blocked_newer();
|
|
blocked_older();
|
|
can_load_history();
|
|
|
|
data = {
|
|
found_oldest: false,
|
|
found_newest: false,
|
|
history_limited: false,
|
|
};
|
|
fetch_status.finish_newer_batch(data);
|
|
fetch_status.finish_older_batch(data);
|
|
|
|
can_load_older();
|
|
can_load_newer();
|
|
can_load_history();
|
|
|
|
reset();
|
|
|
|
can_load_older();
|
|
|
|
fetch_status.start_older_batch();
|
|
|
|
blocked_older();
|
|
can_load_newer();
|
|
can_load_history();
|
|
|
|
fetch_status.finish_older_batch({
|
|
found_oldest: false,
|
|
history_limited: false,
|
|
});
|
|
|
|
can_load_older();
|
|
can_load_newer();
|
|
can_load_history();
|
|
|
|
fetch_status.start_older_batch();
|
|
|
|
blocked_older();
|
|
can_load_newer();
|
|
can_load_history();
|
|
|
|
fetch_status.finish_older_batch({
|
|
found_oldest: true,
|
|
history_limited: true,
|
|
});
|
|
|
|
blocked_older();
|
|
can_load_newer();
|
|
blocked_history();
|
|
|
|
reset();
|
|
|
|
can_load_older();
|
|
can_load_newer();
|
|
|
|
fetch_status.start_newer_batch();
|
|
|
|
can_load_older();
|
|
blocked_newer();
|
|
|
|
fetch_status.finish_newer_batch({
|
|
found_newest: false,
|
|
});
|
|
|
|
can_load_older();
|
|
can_load_newer();
|
|
|
|
fetch_status.start_newer_batch();
|
|
|
|
can_load_older();
|
|
blocked_newer();
|
|
|
|
fetch_status.finish_newer_batch({
|
|
found_newest: true,
|
|
});
|
|
|
|
can_load_older();
|
|
blocked_newer();
|
|
});
|