Commit Graph

123 Commits

Author SHA1 Message Date
Tim Abbott 4db99196e9 message_edit: Fix red highlighting for messages mentioning you.
When we added support for mentioning users when editing messages, we
neglected to add this bit of code needed to make sure the UI code in
message_list_view.js would actually rerender that part of the
message's state.

Arguably, this is a sign that the message_container structure should
be just recomputed every time we rerender messages, but that's a less
tactical fix.
2017-10-23 11:02:30 -07:00
Tim Abbott 391e54f568 message_list: Limit potential damage of auto-scrolling.
We've been getting reports for a few months of folks coming back to
their Zulip window after a night's sleep and finding it scrolled to
the bottom, past dozens or hundreds of messages that they haven't
read.  Oddly, the pointer is actually still located where it should be
(verifiable by hitting the Up key), but it's too late: everything
below gets marked as read because bottom_whitespace is in view.

There's only a few places in the zulip codebase where we scroll the
page down, and this is the main one of them.  My best theory for what
could be happening is that the browser is, in its overnight
power-saving mode, not granting the Zulip window the resources to
actually repaint the early scrolls.  This, in turn, would cause
scrolling down to happen that is not limited by the need to keep the
pointer in view.

I don't think that this fully closes the issue; ideally, we'd have a
reproducer and much more precise detection logic for this situation,
but it should mostly resolve the problem with likely no user-facing
visible harm.
2017-10-06 11:36:33 -07:00
Steve Howell 4d00c390ea Call maybe_rerender when prepending messages to a list.
We had a bug where once you scrolled back far enough
in the message view, your "window" for rendered messages
would be at the max, and `prepend` was not adjusting
the window correctly.  Now we follow the example of
`append` and call `maybe_rerender`.

This partially addresses #6628, where users were
reporting that the home key stopped going up in their
feed.  There was another bug at play for that issue
as well, which is fixed in the next commit.
2017-10-03 11:29:46 -07:00
Tim Abbott a2c21543bc mentions: Fix mention state being lost after reload.
This fixes a regression introduced in
bc2069aec2, which caused @-all mentions
to not be displayed properly.

Fixes #5317.
2017-08-24 23:47:55 -07:00
Tim Abbott 74c628b105 editing: Fix live update of ability to edit messages.
Previously, we didn't check the organization-level settings when
rendering a message list; instead, we only checked it when putting
messages into the message_store.  That resulted in the state being
stale in the event that the setting controlling whether one can edit
messages was changed.

We remove some node tests, because revidving the node test for their
new home in message_list_view would be more work than we probably want
to do with an upcoming release.  We basically need to be better about
exporting functions like populate_group_from_message_container and
set_topic_edit_properties, so we can do fine grained testing.

When we get around to the node tests, rather than exporting these
functions, it might make sense to create a new module with a name
like message_container.js, which would have all of these
last-second type of data manipulations on message objects.  This
would be nice to split out of message_list_view.js.  MLV is our
biggest module, and it's mostly cohesive, but it's real job
should be about assembling messages into a DOM list, which is
probably 80% of the code now.  The 20% that I'd want to consider
splitting out is actually closer in spirit to message_store.js.

Thanks to Steve Howell for helping with the node tests.
2017-08-23 12:03:35 -07:00
Steve Howell 437cabe34c Just use message.unread when rendering.
By the time we render messages, we will have set message.unread,
so we don't need to calculate it from flags.

We add a line to the local-echo path to make this explicit
in that code.
2017-08-04 13:31:26 -07:00
Umair Khan 8921496ccc message_list_view: Add starred_status to message objs.
This starred_status property can be used to provide the context in
the single_message.handlebars template to show the proper tooltip.
2017-06-29 07:39:20 -04:00
Cory Lynch ff9498f85b bookend: Hide re-subscribe button for private streams.
Fixes #5181
2017-06-20 20:56:26 -04:00
Tim Abbott b89be3f54b bookend: Make ordering of subscribe bookends consistent.
Previously, if we had both a date and a subscribe bookend, they would
appear in one order after new messages were sent (bookend_bottom of
the top group), and another after a reload (bookend_top of the bottom
group).  This makes the experience consistently a bookend_top.
2017-06-05 16:43:26 -07:00
Tim Abbott 47465ea51a message_list: Fix missing date boundaries for newly sent messages.
When receiving the first new message of a new day, we were previously
not showing a date separator line before the message.

Fixes a regression introduced
in 00c7f7d42f.
2017-06-05 09:13:02 -07:00
David fcf97660db testing-coverage: add node tests for timerender.js.
Initial set of tests for the timerender.js module.

Fixes #4819.
2017-05-29 08:51:28 -07:00
Tim Abbott 00c7f7d42f Remove date separators from the top of the message feed.
Now that we have the date visible in the recipient rows, we no longer
need a top-of-feed date separator.

Fixes #4581.
2017-05-16 14:47:04 -07:00
Steve Howell 8eb86335b9 Extract narrow_state.js.
Despite the length of this commit, it is a very straightforward
moving of code from narrow.js -> narrow_state.js, and then
everything else is just s/narrow.foo()/narrow_state.foo()/
(with a few tiny cleanups to remove some code duplication
in certain callers).

The only new functions are simple setter/getters that
encapsulate the current_filter variable:

    narrow_state.reset_current_filter()
    narrow_state.set_current_filter()
    narrow_state.get_current_filter()

We removed narrow.predicate() as part of this, since it was dead
code.

Also, we removed the shim for narrow_state.set_compose_defaults(),
and since that was the last shim, we removed shim.js from the app.
2017-04-25 09:57:32 -07:00
Tim Abbott 7d8d9c1bf9 Fix message-edit animations being displayed after sending.
This fixes a regression in 3041480600
that would cause anything rendered on the backend differently than on
the frontend to experience this animation.

We actually only want to do the animation when the message content was
changed in a way that generates an edit history event, i.e. a
user-facing edit, not in cases where we're either transparently
swapping in post-backend-rendering content (e.g. with link previews)
or cases where there's a discrepancy between the exact HTML from the
frontend and backend markdown processes (e.g. mentions).
2017-04-21 11:46:35 -07:00
Brock Whittaker 3041480600 message-edit: Fade in message on update.
When a message update comes back from the server and replaces an
old message, it should fade in. There are two components to the fade:

1. The message fades in from opacity: 0 =>  1.
2. The "edited" text will transform from X: -10 => X: 0.
2017-04-19 22:14:58 -07:00
wangjames e0813c7288 collapse: Fix new messages not being collapsed consistently.
This fixes a bug where newly received very-long messages would only
sometimes be collapsed properly until a second message arrived
(whether it did the right thing dependened on whether the new message
had the same recipient or a different recipient from other arriving
messages).

Apparently, we correctly called condense.condense_and_collapse in all
but one of the codepaths of `render` that add new messages.  This
adds a call on the missing codepath.

Fixes #3978.
2017-03-19 20:39:21 -07:00
Tim Abbott 5e39ccd642 js: Rename viewport.js to message_viewport.js.
This fixes the mobile web experience for Chrome on iOS.

Apparently, Chrome-on-iOS silently has a `viewport` module that
overrides and user-defined module by that name, causing all of our
code that accesses the viewport module to not work on that platform.
We fix this by renaming it.
2017-03-10 14:59:59 -08:00
Tommy Ip abf522adfb Add styling to distinguish bots from human users in message view.
With work by Brock Whittaker and Tim Abbott on rebasing + changing
styling.

Fixes #1107
2017-02-16 17:00:21 -08:00
Durga Akhil M u1604vbox f833f68bfd mute_ui: Add UI for mute on recipient bar.
Like the topic edit pencil icon, the new UI is mostly invisible, but
appears when you hover over the recipient bar.

* Added a tag to hold the mute button in recipient_row.handlebars with
corresponding styling in zulip.css.
* Added an event handler for the mute button in click_handlers.js.

Fixes: #2235.
2017-02-12 00:45:20 -08:00
Steve Howell 44f155e7b2 Generate message.pm_with_url more directly from ids.
We have added people.pm_with_url(message), which computes a
PM url from a private message using user ids rather than emails.

We call this in add_message_metadata(), since the slugs will
be valid even if emails change, so we don't need to compute
them on the fly during message rendering.
2017-02-07 17:37:05 -08:00
Harshit Bansal 50800d4993 Refactor: De-duplicate the message rendering code in message_list_view.js.
Extract the duplicated message template rendering code in
message_list_view.js to `_get_message_template()` helper function.
2017-02-06 22:30:50 -08:00
Steve Howell f836ae0dfb Live-update name changes in the recipient bar.
We now call message_store.get_pm_full_names() when
re-rendering a message list view, rather than reading
msg.display_reply_to, which could be stale.
2017-01-30 11:49:19 -08:00
Steve Howell e7e2e388c5 Move small_avatar_url() to people.js. 2017-01-21 21:45:12 -08:00
Steve Howell 8c6dab9750 Use data-user-id for mention buttons in local echo.
The local echo code now marks up mention buttons with user ids
instead of email.  Our code in message_list_view.js deals with
either the old style or the new style of markup now to determine
which mention buttons need to be highlighted.

As part of this commit we extract mention_button_refers_to_me().
2017-01-21 21:45:12 -08:00
Steve Howell 73125e2718 refactor: Move is_current_user() to people.js.
We no longer have it in util.js, because we will
want to encapsulate this better for upcoming commits
related to email changes.
2017-01-21 21:45:12 -08:00
JefftheBest1 f0afa3e8df Fixed typos with receive 2017-01-12 04:52:44 -08:00
Tim Abbott 998dff9e50 lint: Add dangling commas in JavaScript objects. 2017-01-11 15:23:42 -08:00
Brock Whittaker 3d5c24ab40 Show date correctly on message headers.
This shows a date on a message header whenever the date of that
message is different than the date of the previous message.

The previous logic was bugged and didn't display dates in headers at
date transition points.
2017-01-05 17:28:08 -08:00
Arpith Siromoney 9c64a08cad Add frontend support for emoji reactions.
This commit replaces the placeholder "clipboard" button with a reaction button.
This is done on any message that can't be edited. Also, on messages sent by
the user the actions popover (toggled by the down chevron icon) contains
an option to add a reaction.

When clicked, a popover with a search bar and a list of emojis is displayed.
If the right sidebar is collapsed (the viewport is small), the popover is placed
to the left of the button.
Focus is set to the search bar. Typing in the search bar filters emojis.

Emojis with which the user has reacted to this message are highlighted.
Clicking them sends an API request to remove that reaction.
Clicking on non-highlighted emojis sends an API request to add a reaction.
When the popover loses focus it is closed.

The frontend listens for reaction events. When an add-reaction event is
received, the emoji is displayed at the bottom of the message with a
count initialized to 1. If there was an existing reaction to the message with
the same emoji, the count is incremented.

Old messages fetched from the server contain reactions.
They are displayed (along with title and count) at the bottom
of each message.

When clicking the emoji reaction at the bottom of the message, if the
user has already reacted with that emoji to this message, the reaction
is removed and the count is decremented. Otherwise, a reaction is added
and the count is incremented.

Hovering over the emoji reaction at the bottom of the message displays
a list of users who have reacted with this emoji along with the
emoji name.

Hovering over the emoji reactions at the bottom of the message displays
a button to add a reaction.

Fixes #541.
2016-12-30 21:42:54 -08:00
Rafid Aslam 45f39be37f lint: Fix many no-unused-vars eslint rule violations.
These have been carefully audited by tabbott to ensure they are
unlikely to cause regressions.
2016-12-14 21:34:51 -08:00
Brock Whittaker 80ad28bab5 Don't repeat date header if message date is same as previous.
This primarily works to make sure that new queued messages don’t end up
with redundant date headers on them.
2016-12-14 20:41:33 -08:00
Brock Whittaker a460fcddef Add Date Headers to Floating Bar and Message Headers.
This adds the date of a block of messages to the floating recipient
bar along with message headers of blocks that are the first of a
particular day.
2016-12-13 20:36:39 -08:00
AZtheAsian ed0bc831be eslint: change one-var from warning to error and fix violations 2016-12-02 11:25:16 -07:00
Tommy Ip b3f4feb996 eslint: change max-len from warning to error and fix violations. 2016-12-02 14:16:33 +00:00
Tommy Ip 7b2c313f37 eslint: change brace-style from warning to error and fix violations. 2016-12-01 10:20:22 -08:00
Tim Abbott 47045179fc Fix traceback rendering narrows to non-subscribed streams.
This fixes a bug where Zulip would throw a TypeError if the user were
to try to narrow to a stream they had never been subscribed to.  With
the new "preview" feature on the subscriptions page, this will now
happen much more often.
2016-09-19 22:10:52 -07:00
Tim Abbott c35781d505 lint: Require folding of } on same line as else statements. 2016-06-09 14:02:49 -07:00
Tim Abbott 0c1b5006f7 lint: Check for space after if in javascript. 2016-06-09 13:47:12 -07:00
Tim Abbott b25562ca1d Add and use util.is_current_user helper function.
Previously, we were checking if a particular user was the current user
in dozens of places in the codebase, and correct case-insensitive
checks were not used consistently, leading to bugs like #502.
2016-06-07 21:58:44 -07:00
Tomasz Kolek 0820ab591a Refresh page when message with /me is edited.
Fixes: #163.

Thanks to Catherine Nguyen (@cnguye11) for her work on this.
2016-05-31 08:29:07 -07:00
Vishnu Ks 4be20c4b4a Move scroll_to_selected to navigate.js. 2016-05-27 01:03:21 -07:00
Kartik Maji 3d77aa49db Add subscribe button in narrowed view when stream has no messages.
A temporary message appears on successful subscription, with a button
offering to unsubscribe in case the user subscribed by accident.
2016-05-18 20:06:30 -07:00
Kartik Maji 206452c867 Add stream subscription button added narrowed views.
Fixes: #273
2016-05-18 20:06:23 -07:00
Vishnu Ks ae49ad383d Rename all function on MessageList to all_messages. 2016-04-25 13:45:18 -07:00
Kate Buckner 4d0f7c7ea4 Add a user-visible setting for 24-hour time display.
(imported from commit d934824fd6b72e64a455aac9ff4585b262145f02)
2015-08-20 17:33:16 -07:00
Jacob Hurwitz d401d1cb47 Fix the scrolldown bug (T27850)
(imported from commit 4ae017908b9cc37231ba201c058a6630ceed908f)
2015-01-15 15:26:25 -08:00
Jason Michalski 55e762b069 Fix bug with date separators when prepending messages
When the date changes between an existing group and a new group the
existing date separator needs to be updated. This is done by rerendering
the existing group.

(imported from commit a3775815e33872b0ec07704dc7ccf5fd2671fa21)
2014-03-29 22:00:00 -04:00
Jason Michalski c147daa312 Firefox does not have an innerText so use textContent
textContent is supported on all browsers and IE 9+

(imported from commit ea13d58bf85b6ffb30fdbece20f9dbdcd6c32896)
2014-03-19 17:30:11 -04:00
Jason Michalski 94279c0522 is_me_message is an attribute of the message not the message_container
(imported from commit db36e529de92a82bb9c5df97030833ca2e3e0f80)
2014-03-19 11:43:32 -04:00
Jason Michalski 456e735725 Fix autoscroll forever
(imported from commit 66cc2661767f54de54012b4abf930e748071585e)
2014-03-19 09:38:10 -04:00