Commit Graph

41 Commits

Author SHA1 Message Date
Cynthia Lin c3b1381c2a left sidebar: Make sure the selected stream is visible in left sidebar.
This triggers a scroll in the left sidebar after an initial narrow if
the target stream isn't visible.

Fixes #9043.
2018-07-23 10:32:10 -07:00
Armaan Ahluwalia 6d255efe4c app: Prepare JS files for consumption by webpack.
This commit prepares the frontend code to be consumed by webpack.

It is a hack: In theory, modules should be declaring and importing the
modules they depend on and the globals they expose directly.

However, that requires significant per-module work, which we don't
really want to block moving our toolchain to webpack on.

So we expose the modules by setting window.varName = varName; as
needed in the js files.
2018-07-05 10:53:36 +02:00
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama cc03f9fb8f eslint: Enable space-infix-ops rule.
More about rule at  https://eslint.org/docs/rules/space-infix-ops
2018-06-05 00:47:35 +05:30
Shubham Dhama c6738889a9 eslint: Add and enable `space-unary-ops` rule.
Info about rule at https://eslint.org/docs/rules/space-unary-ops.
2018-06-05 00:47:35 +05:30
Tim Abbott 048f15e975 unread: Fix messages that cannot be marked as read in narrows.
If you visit a narrow that has unread messages on it that aren't part
of the home view (e.g. in a muted stream), then we were never calling
`message_util.do_unread_count_updates`, and more importantly,
`unread.process_loaded_messages` on those messages.  As a result, they
would be unread, and moving the cursor over them would never mark
those messages as read (which was visible through the little green
marker never disappearing).

I can't tell whether this fixes #8042 and/or #8236; neither of them
exactly fits the description of this issue unless the PM threads in
question were muted or something, but this does feel related.
2018-04-23 11:46:46 -07:00
Tim Abbott 1d5204c82b narrow: Fix incorrect values for use_first_unread_anchor.
Apparently, we were incorrectly passing through something related to
opts.use_initial_narrow_pointer as the value for `use_first_anchor`.

If you read the logic in narrow.js carefully,
use_initial_narrow_pointer was unconditionally false.

The correct value for this attribute is when we're trying to narrow to
the first unread message in a given context.  There are two things to
check:

* then_select_id is -1; i.e. we don't have a specific message ID we're
  trying to narrow around.
* select_first_unread is True, i.e. we're trying to narrow to the
  first unread message.

A bit more work should allow us to get rid of the second condition,
but I'm not quite confident enough to do that yet.
2018-04-22 21:33:14 -07:00
Steve Howell 084ef0bea9 Fetch new messages when you scroll forward in narrows.
Note from tabbott: This is a somewhat surprising feature to be adding
this late in Zulip's development, but the model we've had of what
narrows are easy to access via clicking around has meant that it was
fairly difficult to get into a narrow that didn't include the very
latest messages in that narrow.

Fixes #3465.
2018-03-28 09:12:59 -07:00
Steve Howell 4e431516bf Update message_list.all.fetch_status during frontfill. 2018-03-27 18:14:09 -07:00
Steve Howell 60c77ddf6c Update message_list.all in do_backfill(). 2018-03-27 18:14:09 -07:00
Steve Howell a110736584 Use do_backfill() in start_backfilling_messages().
This change mostly de-duplicates code, but it also prevents
some unnecessary backfills if you're in the home view and
happen to scroll back while the idle loop is right in the middle
of a backfill fetch, or if the idle loop has taken you back
to the oldest message already.  This is a consequence of
do_backfill() calling msg_list.fetch_status functions.

Everything else should work pretty much the same, since
do_backfill() computes anchor essentially the same way we
originally doing it in the onIdle() function.
2018-03-21 14:07:00 -07:00
Steve Howell 7242fa8eb8 message_fetch: Extract do_backfill().
This slightly changes the order of operations of what we do in
the `cont` callback, so that we update fetch status earlier.
The order is somewhat arbitrary here, but we generally want to
update data structures first.
2018-03-21 14:07:00 -07:00
Steve Howell e8bc781fd5 Use message_list.all for backfill anchor for home view.
The "all" list and "home" list are basically kept in sync, and
the former is a superset of the latter.

Whenever we are backfilling, we want to backfill "all", so we use
it as the anchor, even though home_msg_list is the message list
we are actually rendering.
2018-03-21 14:07:00 -07:00
Steve Howell f524a095a2 refactor: Extract message_fetch.get_backfill_anchor().
This is just moving code.
2018-03-21 14:07:00 -07:00
Steve Howell 4edf66f927 Track fetch status of initial home message load.
This has a small stylistic change.  The load_more function
is recursive, and we now early-exit when the recursion is
finished (i.e. when we've found the newest row).
2018-03-20 15:23:29 -07:00
Steve Howell df4d325d6c Extract start_backfilling_messages(). 2018-03-20 15:23:29 -07:00
Steve Howell c282b94bab Track fetch status for initial narrow. 2018-03-20 15:23:29 -07:00
Steve Howell 58c1427859 message_fetch: Use found_oldest flag from server.
We now use the found_oldest flag from the server to determine
whether we should load older messages.

This requires us to change a few places in the code where we
pass the whole payload around now instead of just the messages.

Actually, many of the "cont" callbacks don't even look at the
data, so this change wasn't as invasive as I might have
predicted.
2018-03-16 11:42:52 -07:00
Steve Howell 616a06e5b2 Use msg_list.fetch_status instead of load_enabled.
We now attach a fetch_status to message lists, so that they
can track their fetch status individually.  When you go
back in a narrow and get all the older messages, we turn
off future fetches.

The narrow.js code no longer needs to orchestrate anything
here.  The "home" message list won't have as many redundant
fetches after this commit, because we don't need to reset
flags every time we do `narrow.deactivate`.

And then actual narrows get a new message list every time
you narrow, so their fetch status gets reset implicitly
as part of constructing the MessageList object.
2018-03-09 14:20:58 -08:00
Steve Howell 1e446fcb1a refactor: Call message_scroll.hide_indicators() directly.
We are going to remove message_fetch.reset_for_narrow() soon,
but its callers probably still want to hide any scrolling
indicators, and we just let them do that directly.
2018-03-09 14:20:58 -08:00
Steve Howell ec305149be Extract message_fetch.load_messages_for_narrow().
This helps us consolidate the fetching constants without
having to export them.  It will also remove some
responsibility for narrow.js to track fetching state.
2018-03-09 14:20:58 -08:00
Steve Howell 22162a02a8 Remove unused cont_will_add_messages flag.
(It was always false.)
2018-03-09 14:20:58 -08:00
Steve Howell 7bbdf79b78 Rename functions to show_loading_older/hide_loading_older. 2018-03-09 11:04:29 -08:00
Steve Howell 389421d9c2 Rename reset_load_more_status to reset_for_new_narrow.
We are about to make this logic a little more specific to
what happens when you make a new narrow.
2018-03-09 11:04:29 -08:00
Steve Howell ae84908eca Rename load_more_messages to maybe_load_older_messages.
We will soon have maybe_load_newer_messages as well.
2018-03-09 11:04:29 -08:00
Steve Howell 68d3441de1 Rename load_old_messages to load_messages.
This function will eventually sometimes load messages that
are "new" relative to the messages that have already been
loaded.
2018-03-09 11:04:29 -08:00
Steve Howell 47f3af9e50 refactor: Extract constants in message_fetch.js.
Having constants at the top is particularly convenient
for tweaking things while testing the fetch code.
2018-03-08 15:03:47 -08:00
Steve Howell 8063f73f6d Extract message_scroll.js.
This mostly moves code from ui.js.

We change the arguments to `message_fetch.load_more_messages()`
to be `opts` with callbacks for `show_loading` and `hide_loading`.

We also defer starting the scroll handler until `message_fetch.js`
has been initialized.
2018-03-08 15:03:47 -08:00
Steve Howell 7819319695 minor: Remove unused `ui.have_scrolled_away_from_top`. 2018-03-08 15:03:47 -08:00
Steve Howell 4d8d17d134 refactor: Upstream calls to `set_message_booleans`.
We want to call `set_message_booleans` as soon as we
get data from the server, to avoid confusion about whether
`flags` is the authoritative field.

This commit has callers to `add_message_metadata` call
`set_message_booleans`.

This also sets us up to **not** call `set_message_booleans`
in the local echo codepath, where we can just have the
markdown processor set booleans natively.
2017-12-26 09:01:21 -05:00
derAnfaenger 19bc55aa45 Fix various typos.
The typos and their corrections were found with the
aid of https://github.com/lucasdemarchi/codespell.
2017-11-09 16:26:38 +01:00
Steve Howell c2860ce214 Set client_gravatar=True in the webapp.
The webapp knows how to compute gravatar URLs, so there is no need
for the server to send us gravatar URLs.
2017-11-07 16:38:14 -08:00
Rishi Gupta 0286a41c4c tutorial: Remove is_running and defer logic. 2017-08-01 22:38:22 -07:00
Cory Lynch 25be3a402d message_fetch: Move initialization to ui_init.js.
This involves modifying a casper test, because now
upon registration, there is one unread message.
2017-07-04 13:54:33 -07:00
Tim Abbott 8c172063e0 message_fetch: Increase batch size for message backfill to 1000.
There's no advantage to doing a small batch size towards current here,
since latency isn't an issue at this point, and performance on the
server side generally favors larger batch sizes.

This also will make it significantly harder to start getting 429 rate
limiting errors when loading when far behind current.
2017-05-16 18:32:48 -07:00
Rohitt Vashishtha 5be7494ddf Remove duplicate connection-error message.
There's really no need for a separate user-visible error message for
get_messages vs. get_events.

Fixes #4703.
2017-05-09 11:13:27 -07:00
fionabunny 78f2df5649 home.py: move initial_pointer as pointer to register_ret.
This is the last of the fields in page_params that could come from
register_ret but wasn't doing so.
2017-04-28 23:39:14 -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
Brock Whittaker 34f9ccb87c alerts: Change sidebar alerts to be at top of the screen.
This changes the alerts to be individual boxes that slide down from
the top of the screen for a better UI experience.
2017-04-03 16:22:05 -07:00
Steve Howell fd856d728c Extract message_util.js 2017-03-19 21:03:45 -07:00
Steve Howell 1114c8bf62 Extract message_fetch.js. 2017-03-19 21:03:45 -07:00