Commit Graph

62 Commits

Author SHA1 Message Date
Steve Howell bc0761b22b Extract topic_data.js.
This new module tracks the recent topic names for any given
stream.

The code was pulled over almost verbatim from stream_data.js,
with minor renames to the function names.

We introduced a minor one-line function called stream_has_topics.
2017-07-27 14:26:22 -07:00
Steve Howell 0e25055c1d Add explicit message field for locally_echoed.
We now set locally_echoed to true for messages that are
locally echoed, and we change some of our code to look
for this flag.
2017-07-21 11:38:25 -07:00
Steve Howell eb2659a26a local echo: Rename function to notify_local_mixes().
This commit renames possibly_notify_new_messages_outside_viewport()
to the more concise name notify_local_mixes().

We really only need to call this function in one place, so we
have the caller check the `local_id` condition.  We can eventually
upstream this code even further so that it's completely
obvious that it's only ever called from the local-echo codepath.
2017-07-18 12:11:43 -07:00
Steve Howell b5cb21ab2c Remove unneeded call in maybe_add_narrowed_messages().
We were calling maybe_add_narrowed_messages() in a place
where local_id is guaranteed to be undefined, since
we always set local_id to undefined when
can_apply_locally() fails.

In turn maybe_add_narrowed_messages() was calling
possibly_notify_new_messages_outside_viewport(), which
requires a local_id to do anything meaningful.

This removes all the associated dead code--passing in
a parameter that we know always was undefined and
calling a function that we know always would no-op.

Not only does this simplify the code a bit, but it avoids
us stepping on the toes of the alternative code path that
deals with non-locally-echoed messages.
2017-07-18 12:11:43 -07:00
Steve Howell 7d49bb8dbd Extract maybe_advance_to_recently_sent_message.
All the rest of the code in its caller was high-level dispatch
stuff, so it just looked fine of funny.
2017-07-18 12:11:43 -07:00
Durga Akhil Mundroy 146dfa6f0b org-permissions: Add allow_edit_history organiztion setting.
This new setting controls whether or not users are allowed to see the
edit history in a Zulip organization.  It controls access through 2
key mechanisms:

* For long-ago edited messages, get_messages removes the edit history
  content from messages it sends to clients.

* For newly edited messages, clients are responsible for checking the
  setting and not saving the edit history data.  Since the webapp was
  the only client displaying it before this change, this just required
  some changes in message_events.js.

Significantly modified by tabbott to fix some logic bugs and add a
test.
2017-07-16 10:10:06 -07:00
Akhil 6adf241d7e message_edit: Avoid always fetching raw content.
Altered message_edit.start to check for message.raw_content before
retrieving the same from the backend.

With tweaks by tabbott to update, rather than delete, on repeated
edits.

Fixes: #4404.
2017-06-06 22:41:27 -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
Steve Howell 70b7d4c00b Extract compose_state.js.
This is mostly just moving methods out of compose.js.

The variable `is_composing_message`, which isn't a boolean, has
been renamed to `message_type`, and there are new functions
set_message_type() and get_message_type() that wrap it.

This commit removes some shims related to the global variable
`compose_state`; now, `compose_state` is a typical global
variable with a 1:1 relationship with the module by the same
name.

The new module has 100% line coverage, most of it coming
via the tests on compose_actions.js.  (The methods here are
super simple, so it's a good thing that the tests are somewhat
integrated with a higher layer.)
2017-04-18 12:26:58 -07:00
Steve Howell fd856d728c Extract message_util.js 2017-03-19 21:03:45 -07:00
Steve Howell 8d3d70984d Extract message_events.js. 2017-03-19 21:03:45 -07:00