mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
notifications: Refactor code using logic from message_viewport.
Logic for checking if the last message in the current table is visible was already written in message_viewport.js; Code in notifications.js is changed to reduce redundancy.
This commit is contained in:
@@ -562,17 +562,9 @@ function get_message_header(message) {
|
||||
{recipient: 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
|
||||
exports.get_echo_not_in_view_reason = function () {
|
||||
if (message_viewport.bottom_message_visible()) {
|
||||
// If the message is visible, we do not want to notify user
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -628,7 +620,7 @@ exports.notify_local_mixes = function (messages) {
|
||||
|
||||
if (!reason) {
|
||||
// Check if local_echo is not in view
|
||||
reason = exports.get_echo_not_in_view_reason(message);
|
||||
reason = exports.get_echo_not_in_view_reason();
|
||||
if (reason) {
|
||||
exports.notify_above_composebox(reason, "", null, "");
|
||||
setTimeout(function () {
|
||||
|
||||
Reference in New Issue
Block a user