Commit Graph

21 Commits

Author SHA1 Message Date
Yashashvi Dave 784d02bf60 static/js/stream_data: Rename `in_home_view` functions. 2019-05-30 21:39:06 -07:00
Rohitt Vashishtha 1b9ba8c126 zblueslip: Convert node_tests/topic_generator.js to zblueslip. 2018-07-10 16:22:52 -04:00
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04: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
Tim Abbott 6e149a7594 lint: Add JS indentation eslint rules for node_tests.
The only difference between this as the main project's lint rules is
that we dont have the OuterIIFE setting.
2018-05-06 19:35:18 -07:00
Rohitt Vashishtha b22e8dc2b7 lint: Replace 'return undefined;' with 'return;'.
Also adds a custom rule to eslint. Since the recommended way of extending
eslint is to create plugins as standalone npm packages, the separate rule
is published as 'eslint-plugins-empty-returns'.

Fixes #8669.
2018-03-13 08:22:42 -04:00
Steve Howell 6ea2765c9f Add topic_generator.get_next_unread_pm_string().
We will use this for keyboard navigation to cycle through
our unread PM narrows.
2018-02-12 09:34:59 -08:00
Steve Howell c38081b528 node tests: Use zrequire in topic_generator.js. 2017-11-08 12:24:17 -08:00
Steve Howell 770ec92891 hotkeys: Fix "n" key to work inside a muted stream.
Normally the "n" key skips over muted streams, but if we
are currently narrowed inside a muted stream, it will now
go to the next topics within that stream.

For me the use case was that I have a stream I check up on
about once a day, and "n" would be super useful for me to
clear out unread counts while still skimming some content,
and without having to temporarily unmute the stream.
2017-08-17 09:01:49 -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 b4590e1303 Add topic_generator.reverse_wrap_exclude().
This allows us to traverse a list backwards, cycling to the
bottom as needed.

This code is going to be used for the "A" key that cycles
upward in the stream sidebar.  It's probably overkill for
that use case, but it does give us O(1) behavior and avoids
the pitfall of accidentally mutating a list when reversing it.
2017-08-16 15:45:47 -07:00
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 b95e785335 recent topics: Extract get_recent_topic_names().
We now have all of our callers into recent_topics code just
receive a list of topic names from get_recent_topic_names().

This is more encapsulated than handing off tiny little
structures to the three callers, two of whom immediately
mapped the objects to names, and one of whom needlessly
used the now defunct name canon_subject field.

The consolidation here removes some "subject" references, and
now all lookup are by stream id, not stream name.

The diff here is a bit daunting, but it's mostly simplification
of tests and calling code.  Two of the callers now need to look
up stream ids, but they are otherwise streamlined.

The main change here is to stream_data.js, and we replace the
`canon_subject` and `subject` fields with `name`.
2017-07-27 14:26:22 -07:00
Joshua Pan d44626d456 node_tests: Get topic_generator.js to 100% node coverage. 2017-05-23 19:00:56 -07:00
Steve Howell d0ea11f355 Have "n" key skip muted streams. 2017-05-17 11:28:33 -07:00
Steve Howell 6f73b7953f Have "n" key skip muted topics. 2017-05-17 11:28:33 -07:00
Steve Howell 5d33d02235 Track unread counts using stream_id. 2017-05-15 14:47:41 -07:00
Steve Howell 6ddbf12376 Add topic_generator.get_next_topic(). 2017-04-21 21:59:22 -07:00
Steve Howell b27180a645 Have next_topic() return stream/topic objects.
We now use "map" to have our inner generator of topics be
mapped to objects with both the stream and topic.  Thanks to
Mahim Goyal for helping with this design.
2017-04-21 21:59:22 -07:00
Steve Howell d332df8cc6 Add topic_generator.map(). 2017-04-21 21:59:22 -07:00
Steve Howell 262a4d5da6 Create topic_generator.js. 2017-04-06 12:23:44 -07:00