mirror of https://github.com/zulip/zulip.git
notifications: Notify when sent message is scrolled down in view.
A common source of confusion for new users is sending a message when you're scrolled up in the message feed; in this case, it's nice to communicate to the user why the message is not in view. Fixes #10792. Restructured by tabbott to replace overly complex logic for getting the position of the new message with a `message_list.get_row()` call.
This commit is contained in:
parent
022e926d64
commit
372cb20f9e
|
@ -560,6 +560,23 @@ function get_message_header(message) {
|
||||||
return "PM with " + message.display_reply_to;
|
return "PM with " + message.display_reply_to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.get_echo_not_in_view_reason = function (message) {
|
||||||
|
// Check the offset of last message in the current message list;
|
||||||
|
// if it's placement is such that it's below the compose box, we
|
||||||
|
// notify the user.
|
||||||
|
var row = current_msg_list.get_row(message.local_id);
|
||||||
|
var echo_offset_y = row.offset().top;
|
||||||
|
var compose_box_y = $('#compose-container').offset().top;
|
||||||
|
|
||||||
|
if (echo_offset_y > 0 && echo_offset_y < compose_box_y) {
|
||||||
|
// If it lies between top and above the compose box
|
||||||
|
// Message can be said to be visible
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Sent! Scroll down to view your message.";
|
||||||
|
};
|
||||||
|
|
||||||
exports.get_local_notify_mix_reason = function (message) {
|
exports.get_local_notify_mix_reason = function (message) {
|
||||||
var row = current_msg_list.get_row(message.id);
|
var row = current_msg_list.get_row(message.id);
|
||||||
if (row.length > 0) {
|
if (row.length > 0) {
|
||||||
|
@ -604,6 +621,15 @@ exports.notify_local_mixes = function (messages) {
|
||||||
var reason = exports.get_local_notify_mix_reason(message);
|
var reason = exports.get_local_notify_mix_reason(message);
|
||||||
|
|
||||||
if (!reason) {
|
if (!reason) {
|
||||||
|
// Check if local_echo is not in view
|
||||||
|
reason = exports.get_echo_not_in_view_reason(message);
|
||||||
|
if (reason) {
|
||||||
|
exports.notify_above_composebox(reason, "", null, "");
|
||||||
|
setTimeout(function () {
|
||||||
|
$('#out-of-view-notification').hide();
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
|
||||||
// This is more than normal, just continue on.
|
// This is more than normal, just continue on.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue