Commit Graph

211 Commits

Author SHA1 Message Date
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 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 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
Abhigyan Khaund a75f0aa594 hotkeys: Add "p" to narrow to next unread PM thread.
This works simimlar to the "n" key for next topics.

This commit does a few things:

    * It wires up the hotkey to an existing function
      that could change narrows.
    * It adds documentation.
    * It adds logic to make sure the compose box does
      not open.

@showell helped a bit with the wording of comments here.

Fixes #4874
2018-02-27 07:20:31 -05:00
Steve Howell 46a49777c4 Add stream ids to urls for stream-related narrows.
This commit prefixes stream names in urls with stream ids,
so that the urls don't break when we rename streams.

strean name: foo bar.com%
before: #narrow/stream/foo.20bar.2Ecom.25
after: #narrow/stream/20-foo-bar.2Ecom.25

For new realms, everything is simple under the new scheme, since
we just parse out the stream id every time to figure out where
to narrow.

For old realms, any old URLs will still work under the new scheme,
assuming the stream hasn't been renamed (and of course old urls
wouldn't have survived stream renaming in the first place).  The one
exception is the hopefully rare case of a stream name starting with
something like "99-" and colliding with another stream whose id is 99.

The way that we enocde the stream name portion of the URL is kind
of unimportant now, since we really only look at the stream id, but
we still want a safe encoding of the name that is mostly human
readable, so we now convert spaces to dashes in the stream name.  Also,
we try to ensure more code on both sides (frontend and backend) calls
common functions to do the encoding.

Fixes #4713
2018-02-19 09:03:11 -08:00
Steve Howell 35cc206dcc Add narrow.narrow_to_next_pm_string().
This helper function will allow us to cycle through PM narrows
that are unread, once we map it to a hotkey and/or other UI.

(We intend to make something like the "n" key for topics, but
that works on PM narrows instead.)
2018-02-12 09:34:59 -08:00
YJDave de13dd41c2 stream narrow: Set message if narrows to never-subscribed private stream.
If user narrows to never-subscribed private stream, display
nonsubbed_private_nonexistent_stream_narrow_message.
2018-01-04 16:52:54 -05:00
Rishi Gupta 191f8f1b39 left sidebar: Change Home to All messages.
We made this change because users often unnecessarily click "Home"
first in their use of Zulip, because it seems appealing.  While "All
messages" isn't quite precise (it doesn't include muted streams), it
does describe relatively simply the interleaved view that this
represents.

This commit leaves everything as "home" in the code, and only changes
user-visible strings and docs. Changing the code will be a big project;
there are hundreds of relevant occurrences in variable names, etc.

Further, we'll probably want to convert those various variable names
in different ways.

Tweaked by tabbott to extend the commit message and update a few comments.
2017-11-28 15:42:58 -08:00
Alena Volkova 5515a075ec urls: Move the report endpoints to be API-style routes. 2017-10-17 22:05:56 -07:00
Tim Abbott 82b708b721 eslint: Add and enforce space-in-parens lint rule. 2017-10-06 12:36:59 -07:00
Cory Lynch 1c0043ea47 Add empty narrow msg for group-pm-with.
Also added test case.
2017-09-24 15:13:58 -04:00
Abhijeet Kaur 2bf3324395 frontend: Add ability to search by "group-pm-with" search operator.
This allows user to view all group private conversation messages
with a specific user. That is, it views all the the group private
messages from groups which include the given user.

Add search suggestion for group-pm-with. Add operator name
and description in "Search operators" tab.

Add change in tab name to "Group Messages" when using this operator.
Add frontend_tests for group-pm-with search operator.

Fixes: #3882.
2017-09-24 11:58:48 -04:00
Tim Abbott 57dfded339 narrow: Add some clarifying comments. 2017-08-23 12:43:11 -07:00
Steve Howell 29c05c82f0 Fix A/D hotkeys for cycling through stream narrows.
We now use similar code for A/D hotkeys as we do for the "n"
key.

The old code was using jQuery operations that got tripped up
by our splitters between active and inactive streams.

Fixes #4569
2017-08-16 15:45:47 -07:00
Steve Howell 57f17ae543 Extract top_left_corner.js.
Here are the functions in top_left_corner:

    get_global_filter_li: pure code move
    update_count_in_dom: simplifed copy of similar function in stream_list.js
    update_dom_with_unread_counts: pure code move, split out from function
       of same name in stream_list.js
    delselect_top_left_corner_items: pure code move
    handle_narrow_activated: pure code move + rename
    handle_narrow_deactivated: pure code move, split out from from function
       of smae name in stream_list.js
2017-08-14 13:03:57 -07:00
Steve Howell 0f3b565d40 Create explicit handlers for stream activate/deactivate.
Calling explicit functions ensurest that the sidebars
get activated for narrows before less important things
happen, and it also makes testing easier.
2017-08-14 13:03:57 -07:00
Tim Abbott 5f87037bf5 Fix upwards scrollback when narrowing to streams centered on old messages.
Previously, when you switched to a stream narrow with the central
message outside the range of messages cached in the browser, we would
reset the UI for loading more messages, but not actually reset the
state for whether it should be possible.

This seems to have been an oversight in refactoring back in 2014.

Fixes #6109.
2017-08-14 12:05:40 -07:00
Steve Howell 5a10137ad9 Extract message_list.first_unread_message_id().
This de-duplicates code that solved the same problems using
two different phrasings.
2017-08-03 11:32:54 -07:00
Vaida Plankyte 5a3d3ae291 narrow.js: Use the singular 'they' pronoun. 2017-07-05 09:27:43 -07:00
Cory Lynch c19be5e39e Change conversation links to contain user's own email.
Fixes #2360.
2017-06-20 21:22:45 -04:00
Cory Lynch 86d3e00bd0 Add search support for is:unread.
Fixes #1423.
2017-06-19 06:51:13 -04:00
Steve Howell 34f26f14aa narrow: Remove redundant from_reload option.
The narrowing option from_reload was only used in
conjunction with use_initial_narrow_pointer, but the
latter option already takes into account whether a
reload happened.
2017-06-15 12:16:27 -07:00
Steve Howell 961d54692e narrow: Rename var to use_initial_narrow_pointer. 2017-06-15 12:16:25 -07:00
Cynthia Lin 09419aa027 hotkeys: Allow `n` key to work on PMs.
Fixes #4885
2017-05-31 18:00:57 -06:00
Steve Howell cc81b7892d Add process_visible() call to maybe_select_closest().
This fixes a regression where we removed a call to
unread_ops.process_visible() inside of stream_list.js.  Now
we call it from within narrow.activate() in the the
maybe_select_closest() callback.
2017-05-31 12:40:57 -06:00
Rohitt Vashishtha 2d73e03e37 ui-refactor: Rename modals.js to overlays.js.
Fixed #4702.
2017-05-29 11:24:46 -07:00
Steve Howell 3ca10dd6f5 Select first unread message when using the "n" key. 2017-05-17 11:28:33 -07:00
Tim Abbott 40e43d8cba narrow: Remove unused by_conversation_and_time and by_id helpers.
Now that we just copy links to the clipboard, neither of these are
used.  (Actually, the narrow.by_id helper has been dead code for
years).
2017-05-09 09:59:37 -07:00
Mahim Goyal 6fe0728afa Return absolute URL from narrow.by_conversation_and_time_uri 2017-05-09 09:55:38 -07:00
Steve Howell 742c55f514 Speed up key handling by adding modals.is_active().
The function modals.is_active() can see if modals are open
without having to look at the DOM.  This should make it snappier
to type in the compose box.  Even if the speedup is pretty minor,
not having to worry about jQuery slowness should make it easier
to diagnose future compose box issues.

The new function gets used in other places, too, where performance
isn't so much an issue.
2017-05-08 22:04:56 -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
Steve Howell d938afaedc Extract narrow.narrow_to_next_topic().
This borrows some code from a PR from Mahim Goyal.
2017-04-22 11:46:47 -07:00
Steve Howell ddbe877909 Add narrow.stream_topic(). 2017-04-21 21:59:22 -07:00
Steve Howell c7a9a02667 Consolidate code for narrow/compose interactions.
This commit extracts the method compose_actions.on_narrow()
to handle changing the compose box (as appropriate) after
any narrowing action.

This change should be mostly non-user-facing, but it's not
exactly a trivial extraction.

For the case where the user already had content in their
compose box, we continue to leave the compose box alone,
but we now update compose fading 150+ lines later in
narrow.activate().

Likewise, for cases where we cancel composing, this will
also happen later in the function.

Finally, for PM narrows, where we auto-open the compose box, we
no longer call compose.cancel() before calling compose.start(),
because either a) the compose box would have not been open
in the first place or b) the start() function can handle
clearing the old fields.
2017-04-19 10:06:00 -07:00
Steve Howell 78803b2e56 Add narrowed_by_topic_reply() helper. 2017-04-17 22:54:36 -07:00
Steve Howell 9d4f0bf704 Open compose box more aggressively for PM narrows.
We now auto-open the compose box whenever somebody narrows to
a "pure" PM narrow.  We already did this for buddy list clicks,
so this make it work the same for other ways of narrowing to
PM conversation.  Here, we optimize for composing, vs. reading,
since PM conversations tend to have lots of back and forth.

(Contrast this to stream conversations, where there's a higher
likelihood of lurking or doing a quick narrow to re-read some
message from the stream.)
2017-04-17 22:54:36 -07:00
Steve Howell bdca28a14b Avoid opening compose box for topic sidebar clicks.
We don't want to auto-open the compose box for topic
sidebar clicks, because we want to convenience folks
reading messages, not writing messages, since on
stream narrows, people tend to do much more reading
than writing.  (Also, opening the compose box explicitly
is super easy.)

The part of this change that affects behavior is that
we remove the call to compose_actions.start('stream').

Then the simplification is that we replace the checks
to narrowed_by_reply() and !narrowed_to_topic() with
a single call to narrowed_by_pm_reply().

Fixes #3886.
2017-04-17 22:54:36 -07:00
Steve Howell af887822b5 Add narrowed_by_pm_reply() helper. 2017-04-17 22:54:36 -07:00
Steve Howell 33eb5ad237 Add narrow.is_for_stream_id() helper. 2017-04-13 07:49:55 -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
Steve Howell d026344b37 Extract js/ui_util.js. 2017-03-19 11:05:45 -07:00
Steve Howell 5b2407bb22 Add ui_state.home_tab_obscured() shim. 2017-03-19 10:56:09 -07:00
Rishi Gupta 19d8d16126 js dependencies: Split hash_util.js from hashchange.js. 2017-03-18 20:40:34 -07:00
Steve Howell 27f37e6378 Add hash_util.encodeHashComponent() shim. 2017-03-18 15:52:50 -07:00
Steve Howell d75efa19db Add compose_state.has_message_content() shim. 2017-03-18 15:52:50 -07:00
Steve Howell 59fd9e4d48 Add compose_actions.cancel() shim. 2017-03-18 15:52:50 -07:00
Steve Howell faa9446e64 Add compose_actions.start() shim. 2017-03-18 15:52:50 -07:00
Steve Howell a51caceea5 refactor: Extract unread_ops.js
This module mostly contains the mark_* functions that
update the server with info about unread counts.
2017-03-18 10:35:52 -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
Steve Howell 0bd3af2bc8 Create narrow.update_email(). 2017-02-14 23:25:22 -08:00
Elliott Jin 4092aab620 unread: Refactor to move DOM element updates into UI layer. 2017-02-11 08:36:39 -08:00
sinwar 21083278b5 Fix banners for unknown streams.
Fixes #3443
2017-01-28 13:11:31 -08:00
Steve Howell cd6115c24d Make nicer slugs for "sender" narrows.
Slugs are now like our "pm-with" slugs:

    narrow/sender/3-cordelia
2017-01-19 14:54:50 -08:00
Steve Howell c94b8c39d0 Add narrow.huddle_with_uri() convenience method.
This will be used in a subsequent commit.
2017-01-17 15:13:49 -08:00
Steve Howell d757f840dd Make nicer slugs for "pm-with" narrows.
The slugs for PM-with narrows now have user ids in them, so they
are more resilient to email changes, and they have less escaping
characters and are generally prettier.

Examples:

    narrow/pm-with/3-cordelia
    narrow/pm-with/3,5-group

The part of the URL that is actionable is the comma-delimited
list of one or more userids.

When we decode the slugs, we only use the part before the dash; the
stuff after the dash is just for humans.  If we don't see a number
before the dash, we fall back to the old decoding (which should only
matter during a transition period where folks may have old links).

For group PMS, we always say "group" after the dash. For single PMs,
we use the person's email userid, since it's usually fairly concise
and not noisy for a URL.  We may tinker with this later.

Basically, the heart of this change is these two new methods:

    people.emails_to_slug
    people.slug_to_emails

And then we unify the encode codepath as follows:

    narrow.pm_with_uri ->
    hashchange.operators_to_hash ->
    hashchange.encode_operand ->
    people.emails_to_slug

The decode path didn't really require much modication in this commit,
other than to have hashchange.decode_operand call people.slug_to_emails
for the pm-with case.
2017-01-17 15:13:49 -08:00
Tim Abbott 998dff9e50 lint: Add dangling commas in JavaScript objects. 2017-01-11 15:23:42 -08:00
Tim Abbott f0f4be4af7 lint: Fix remaining no-unused-vars eslint rule violations. 2016-12-14 22:36:47 -08:00
AZtheAsian 5e9918135b eslint: change quote-props from off to error and fix violations. 2016-12-02 18:35:53 -08:00
AZtheAsian 9c0ebc7359 eslint: change no-else-return to error and fix violations 2016-12-02 14:43:09 -08:00
Tommy Ip b3f4feb996 eslint: change max-len from warning to error and fix violations. 2016-12-02 14:16:33 +00:00
Steve Howell 853126344e Add narrow.topic() helper method.
This has similar semantics to narrow.stream().
2016-11-10 15:55:31 -08:00
Steve Howell eb64b32bc8 Fix "subjects" in JS comments. Say "topics" instead. 2016-10-28 13:52:25 -07:00
Tim Abbott 2867c019cb Don't show special empty narrow messages for complex narrows.
Previously we showed an empty narrow error message determined entirely
by the first operator, even though there could have been multiple
operators.
2016-07-31 19:38:19 -07:00
Kartik Maji cea079279e Improve error message when narrowed to nonexistant or silent users.
Fixes #1418.
2016-07-31 19:38:17 -07:00
krtkmj 734ab8d5e3 Correctly narrow to stream using search box from subscription page.
Fixes #1012.
2016-06-23 15:20:57 -07:00
Tim Abbott c35781d505 lint: Require folding of } on same line as else statements. 2016-06-09 14:02:49 -07:00
Vishnu Ks e329c9e0f5 Move maybe_scroll_to_selected to navigate.js. 2016-05-27 01:03:21 -07:00
Vishnu Ks fe4a03fd01 Move narrowed_msg_list to message_list.js. 2016-04-26 10:25:11 -07:00
Vishnu Ks ae49ad383d Rename all function on MessageList to all_messages. 2016-04-25 13:45:18 -07:00
Vishnu Ks 35b0af2852 Move all_msg_list to message_list.js. 2016-04-21 17:46:21 -07:00
Vishnu Ks ee39f5009f Make message_list.js work like the other modules. 2016-04-20 15:29:30 -07:00
Aristeidis Fkiaras 0058ccbdb0 Move global unread_messages_read_in_narrow to unread.js. 2016-04-08 12:11:47 -07:00
Liz Sander 860cf68716 Show current narrow in page title.
Fixes issue #157.
2015-12-14 21:21:30 -08:00
Steve Howell f8b71fa497 Created condense.js (with code taken from ui.js).
(imported from commit 72b27b48614a7c396170d46936646e52757e2743)
2014-03-14 20:48:58 -04:00
Leo Franchi 748e5b6da6 Remove disabled summarization code
This experiment has been disabled for everyone for a while: if we
bring something like this back, it is not likely to be exactly the same,
and will be different enough to require a different implementation.

As it is, the summarization code was making a few code paths (rendering
especially) more complex, and is worth removing for simplicity's sake.

(imported from commit 6ac8cdc9f7077a5a1da01ab4268aba3db0bc43f8)
2014-02-27 20:25:23 -05:00
Leo Franchi acec697fe7 Report unnarrow times as well as narrow times
(imported from commit b3a889aa11dc112508c5a1d213f68e5223a879fc)
2014-02-13 14:45:22 -05:00
Tim Abbott fcb8c106b1 Fix saving of pointer on server-initiated reload when narrowed.
Previously, we saved the current_msg_list selected id and then
restored it as the home_msg_list selected id, which could result in
the home view loading to the wrong place.

This takes some already bad code and makes it even more in need of
refactoring, but it does fix a pressing bug.  We should definitely
refactor both:

* the top of narrow.js
* the save/restore code in reload.js

after this, though.

(imported from commit bb2040219e4f545ba90bb04a696996cec2831484)
2014-02-12 14:40:38 -05:00
Steve Howell 10b24f77b6 Fix misc. uses of search tuples.
(imported from commit c7dc47c1396eb0d9f6821cafcb3dc90d283b4764)
2014-02-10 15:11:43 -05:00
Steve Howell 8d81ea33da Have pick_empty_narrow_banner() use operator/operand.
This is part of phasing out the internal tuple representation.

(imported from commit aa8788efbdc0f8d08d99bae154f68a3b60272c65)
2014-02-10 13:23:26 -05:00
Tim Abbott 02d69f18ac Clean up codepath for selecting a message on unnarrowing.
This does have a small functional change of using use_closest even for
the current_msg_list.last().id case, but that's harmless; and it does
reduce a lot of code duplication and confusing logic here.

(imported from commit 7c4ecaa197120cc6d5c05ce4887f33c7d94a9c59)
2014-02-06 10:25:35 -05:00
Jason Michalski 0dd61e9222 Blueslip has a warn not warning function
(imported from commit 1f18331cac451c62a089f042b316278030c41965)
2014-02-04 23:08:19 -05:00
Tim Abbott 0b12681558 Export message_store.get() for getting message objects.
(imported from commit d7d20bf3aab62a1b407709b1c0bf947b3ad8bee8)
2014-02-03 13:32:02 -05:00
Tim Abbott f26af47fb6 Center on-page-load narrows on first unread message.
This implementation is somewhat hackish in large part because I think
we're going to be wanting to redo the get_old_messages API somewhat
soon, and this may naturally become a lot cleaner as a result, but
this isn't a lot of code and fixes #2235 part (A) and substantially
mitigates #1510.

(imported from commit 47a2160a44befa9d83190c5cc95b90e92cc5b4cc)
2014-02-03 13:32:02 -05:00
Tim Abbott 88fbd5d16a Split out new module message_store.js.
(imported from commit 57cf3f2b8e74d7c56e3baf75859d5b3646282225)
2014-01-31 15:57:28 -05:00
Tim Abbott 004fd0eab8 Move unread-related functions from zulip.js to unread.js.
(imported from commit efc0dd84c2cd30b0203b906af6991475d8a63985)
2014-01-31 14:59:03 -05:00
Leo Franchi 01e948ac97 Allow unnarrowing to an empty message list in unread-messages-read case
(imported from commit f377dbce61fe2fc2051bc286f7215e8112f92736)
2014-01-30 18:08:48 -05:00
Steve Howell 15b0f9dcc7 Use operator/operand in narrow.collect_single().
(This is part of converting away from tuples.)

(imported from commit ba3083f8b3242fee1d532d7666aee68af89d8ddc)
2014-01-30 16:15:16 -05:00
Steve Howell 796ebfd007 Do not return raw operators from narrow.operators().
Even in the case where we are running embedded narrows,
we want narrow.operators() to return new-style operators
that you get with Filter objects, so that callees do
not need to support the legacy tuple format.

(imported from commit a6649881a926a2304e9f7cc8ca53b406e2c8828e)
2014-01-30 16:15:14 -05:00
Steve Howell b3a551f402 Stop using raw operators in narrow.activate().
Have narrow.activate() user filter.operators() to produce
operators that have operand/operator fields, so that its callees
don't need to be backward compatible with the tuple format.

(imported from commit e408e33074d1be2d112bb3cdc081ec3616c908ee)
2014-01-30 15:57:28 -05:00
Jason Michalski 21c2aea755 Fix scroll position on narrow and unnarrow
Change the offset to hold of the selected message as an offset from the
top of the screen. Then use the current offset and scrollTop to compute
the new scrollTop.

(imported from commit 718e95d3435c0f84cbb7663a9bb2bc2789314203)
2014-01-30 01:48:15 -05:00
Leo Franchi dd7d31c7a6 Allow an empty home view when unnarrowing
(imported from commit 69f1a84b23ae8942db58851a1a1c6723c26df560)
2014-01-28 15:35:31 -05:00
Leo Franchi 1fdb586c13 Make sure then_select_id is a number to call .toFixed()
(imported from commit 58635110c737ccb38e74cce8b4feb5d93dfbf5cc)
2014-01-27 12:30:42 -05:00
Leo Franchi 00f64113e9 Support locally echoing messages when sending
(imported from commit 00b5c5f9b933d119553c32cadff0f17b9f7c2879)
2014-01-23 16:28:55 -05:00
Leo Franchi 49c4ad61a1 Delay render on narrowing to end, to ensure only one render happens
(imported from commit c38574417e339275a90b235ecabc96e0deab95f8)
2014-01-23 13:29:18 -05:00