Commit Graph

12 Commits

Author SHA1 Message Date
Steve Howell 37c78abe14 frontend: Use topic on message.
This seems like a small change (apart from all the
test changes), but it fundamentally changes how
the app finds "topic" on message objects.  Now
all code that used to set "subject" now sets "topic"
on message-like objects.  We convert incoming messages
to have topic, and we write to "topic" all the way up
to hitting the server (which now accepts "topic" on
incoming endpoints).

We fall back to subject as needed, but the code will
emit a warning that should be heeded--the "subject"
field is prone to becoming stale for things like
topic changes.
2019-01-07 19:20:56 -08:00
Steve Howell 7642ed66cf Expand get_unread_ids() to all local narrows.
This commit makes it so that any query for
which we do a local filter leads to us
examining the full list of unread message
ids in our cache to find a potentially
unread message that passes the filter.  This
can often allow us to more immediately
jump to a new narrow with an appropriately
selected message.

Fixes #9319
2018-05-31 08:44:18 -07:00
Steve Howell 4c235bfe65 Handle non-local case in get_first_unread_info().
We want to be able to call get_first_unread_info() even
if we cannot apply a search locally.  It was returning
the correct value before, but this change removes a
blueslip warning that will allow our callers to remove
some guard code in a subsequent commit.
2018-05-31 08:44:18 -07:00
Steve Howell 42435db492 Add run_test helper for individual tests.
This run_test helper sets up a convention that allows
us to give really short tracebacks for errors, and
eventually we can have more control over running
individual tests.  (The latter goal has some
complications, since we often intentionally leak
setup in tests.)
2018-05-15 08:24:44 -07:00
Steve Howell 0c9cf12933 Avoid some server fetches for sender:foo queries.
If we find unread messages for a sender, we will
try to render locally narrow for sender searches.

Note that our current implementation brute forces
through all the unread ids.  We can improve this,
although it's not really a bottleneck until we
also support buckets for general filtering.
2018-05-13 08:47:55 -07:00
Steve Howell 815f54cda4 Use local messages for more narrow searches.
We now try harder to find the first unread message in an
upcoming narrow, which has the user-visible effect that we
select the unread message before waiting for search results.

Before this change, we only applied this logic to searches
that were things like exactly stream/topic or exactly is-private.

Now we will also handle things like stream/topic/sender.  For
the stream/topic piece we look up candidate unread ids using
the steam/topic buckets in unread.js, but then we still filter
those messages by stream/topic/sender as we look for the first
unread id.
2018-05-10 06:36:13 -04:00
Steve Howell 124192a3b9 node tests: Clean up narrow_unread messages.
This gives variable names to each of the messages we use.
2018-05-10 06:36:13 -04:00
Steve Howell 5d6d1ca8f9 refactor: Rename narrow_state.get_unread_ids().
I renamed get_unread_ids() to _possible_unread_message_ids().
The name is deliberately verbose, since we're about
to make it have kind of unusual semantics that only make sense
for its one caller.

The outside code will continue to call get_first_unread_info().

In the tests I wrap this function in a wrapper with the more
pleasant name of "candidate_ids", since in the test there's
less worry about unwittingly exposing a kind of janky function.
2018-05-10 06:36:13 -04:00
Steve Howell a68fa980d3 Add starred messages to our new API for unread ids.
Even though starred messages are never unread, it's useful
for us to have helper functions for them.

This change makes it so that clicking on "Starred Messages"
takes you to the last read message immediately, without a
server delay.
2018-05-03 14:36:34 -07:00
Steve Howell 3e19efca36 Change narrow.get_first_read_id -> get_first_read_info.
This function, which is only used in tests so far, needs
to return something more meaningful than undefined when
we don't find an id.
2018-05-03 12:44:30 -07:00
Steve Howell 66cd2edee4 Add narrow_state.get_first_unread_id(). 2018-05-02 13:34:54 -07:00
Steve Howell 230ecb24ed Add narrow_state.get_unread_ids(). 2018-05-02 11:23:58 -07:00