narrow: Move the top of narrow notices to message_scroll.js.

We refactor these 2 notices to match with the loading indicators,
thus they have been moved to `message_scroll.js`.

After a successful message fetch, we have logic to decide whether
we want to display the notices and also whether we want to hide
the loading indicators (which are already displayed).

We also conservatively hide the notices similar to the indicators
every time we narrow.
The only exception is that we show the history limit notice on
deactivating the narrow (visiting `home_msg_list`).
This commit is contained in:
Ryan Rehman
2020-06-14 16:03:12 +05:30
committed by Tim Abbott
parent 31b6867360
commit c7e39ef090
6 changed files with 66 additions and 66 deletions

View File

@@ -41,6 +41,65 @@ exports.hide_indicators = function () {
exports.hide_loading_newer();
};
exports.show_history_limit_notice = function () {
$(".top-messages-logo").hide();
$(".history-limited-box").show();
exports.hide_empty_narrow_message();
};
exports.hide_history_limit_notice = function () {
$(".top-messages-logo").show();
$(".history-limited-box").hide();
};
exports.hide_end_of_results_notice = function () {
$(".all-messages-search-caution").hide();
};
exports.show_end_of_results_notice = function () {
$(".all-messages-search-caution").show();
// Set the link to point to this search with streams:public added.
// It's a bit hacky to use the href, but
// !filter.includes_full_stream_history() implies streams:public
// wasn't already present.
$(".all-messages-search-caution a.search-shared-history").attr(
"href", window.location.hash.replace("#narrow/", "#narrow/streams/public/")
);
};
exports.update_top_of_narrow_notices = function (msg_list) {
// Assumes that the current state is all notices hidden (i.e. this
// will not hide a notice that should not be there)
if (msg_list !== current_msg_list) {
return;
}
if (msg_list.data.fetch_status.has_found_oldest() &&
current_msg_list !== home_msg_list) {
const filter = narrow_state.filter();
// Potentially display the notice that lets users know
// that not all messages were searched. One could
// imagine including `filter.is_search()` in these
// conditions, but there's a very legitimate use case
// for moderation of searching for all messages sent
// by a potential spammer user.
if (!filter.contains_only_private_messages() &&
!filter.includes_full_stream_history() &&
!filter.is_personal_filter()) {
exports.show_end_of_results_notice();
}
}
if (msg_list.data.fetch_status.history_limited()) {
exports.show_history_limit_notice();
}
};
exports.hide_top_of_narrow_notices = function () {
exports.hide_end_of_results_notice();
exports.hide_history_limit_notice();
};
exports.actively_scrolling = function () {
return actively_scrolling;
};