Commit Graph

28 Commits

Author SHA1 Message Date
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00
Anders Kaseorg bcab7efb37 js: Use XDate as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-28 10:54:35 -07:00
Anders Kaseorg b65d2e063d js: Reformat with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:25 -07:00
Anders Kaseorg f3726db89a js: Normalize strings to double quotes.
Prettier would do this anyway, but it’s separated out for a more
reviewable diff.  Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:24 -07:00
Steve Howell 39f18c1b4e node test: Remove unnecessary zrequires.
Some extraneous zrequires were added in
3bc818b9f7

This is not a huge deal, but it makes it
appear as if data modules are dependent
on things that they don't really care
about.  The tests should provide a bit
of signal on how "deep" an object's
dependencies go.
2020-04-22 18:54:27 -04:00
Ryan Rehman 3bc818b9f7 muting ui: Update the muted topics table in settings.
The set_up_muted_topics_ui and templates have been
refactored to use list_render.
This is done to support filtering and sorting of
the muted stream topics.

This also includes the addition of a new Date muted header.
2020-04-22 15:07:15 -07:00
Rohitt Vashishtha c8b0627ffe zblueslip: Run blueslip.reset after each test.
This simplifies the blueslip interface to just declaring expected
errors and calling the code to test.
2020-04-20 08:17:20 -04:00
Steve Howell f7b432afec node tests: Auto-include zblueslip for node tests.
We already use blueslip stubs in ~45 tests, so we
may as well just auto-include it.
2020-04-03 12:56:49 -04:00
Steve Howell df84c52a7f zblueslip: Change API to expect/reset.
The `set_test_data` never made complete sense to
me, since it wasn't really data that we were
setting.
2020-04-03 12:56:49 -04:00
Steve Howell 2788ebdde7 minor: Clean up blank lines in tests. 2020-04-03 12:56:49 -04:00
Steve Howell b994889315 node tests: Just set i18n every time.
Explicitly stubbing i18n in 48 different files
is mostly busy work at this point, and it doesn't
provide much signal, since often it's invoked
only to satisfy transitive dependencies.
2020-02-28 17:11:24 -08:00
Steve Howell fa1059aa2e stream_data: Remove stream_name param from add_sub().
We just get the stream_name from the sub struct now.

This mostly affects node tests.

The only place in real code where we called add_sub()
was when we initialized data from the server.
2020-02-09 22:08:50 -08:00
Ryan Rehman 174b2abcfd settings: Migrate to stream_post_policy structure.
This commit includes a new `stream_post_policy` setting,
by replacing the `is_announcement_only` field from the Stream model,
which is done by mirroring the structure of the existing
`create_stream_policy`.

It includes the necessary schema and database migrations to migrate
the is_announcement_only boolean field to stream_post_policy,
a smallPositiveInteger field similar to many other settings.

This change is done to allow organization administrators to restrict
new members from creating and posting to a stream. However, this does
not affect admins who are new members.

With many tweaks by tabbott to documentation under /help, etc.

Fixes #13616.
2020-02-04 17:08:08 -08:00
Anders Kaseorg 052497de1c muting: Replace muted_topics Dict with IntDict.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-02 20:37:41 -08:00
Anders Kaseorg 28f3dfa284 js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint
--only=eslint --fix`.  It was then modified by tabbott to contain only
changes to a set of files that are unlikely to result in significant
merge conflicts with any open pull request, excluding about 20 files.
His plan is to merge the remaining changes with more precise care,
potentially involving merging parts of conflicting pull requests
before running the `eslint --fix` operation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-03 12:42:39 -08:00
Steve Howell a4c80089f3 page load: Fix two bugs related to muting/unreads.
The first bug fixed here has been around for a long
time--we were redundantly updating unread counts
indirectly via muting_ui.initialize(). The
unread counts also get updated in
unread_ui.initialize(), when we have more valid
state.  (And it's worth noting here that the unread
counts get updated yet again once message fetches
complete.)

The second bug was a very recent regression from
my recent stream name -> stream id cleanup in the
muting system.  We now depend on stream_data to
initialize muting data, so we need to initialize
muting.js slightly later in the process.

These fixes are intertwined, because they were both
somewhat caused by the anti-pattern of having
muting_ui.js initialize unread_ui.js and muting.js,
instead of doing more direct, fine-grained initialization
from ui_init.js.

Essentially we replace this code:

    exports.update_muted_topics = function (muted_topics) {
        muting.set_muted_topics(muted_topics);
        unread_ui.update_unread_counts();
    };

with this:

    exports.initialize = function () {
        exports.set_muted_topics(page_params.muted_topics);
    };

And the modules load like this:

    stream_data
    ...
    muting
    ...
    unread_ui

And we don't need any page-load initialization for muting_ui,
which is mostly used for Settings/Muted topics.
2018-12-15 13:44:30 -08:00
Steve Howell 87851b0db0 muting: Use stream_id in muting.get_muted_topics(). 2018-12-14 16:05:37 -08:00
Steve Howell a8718c9051 muting: Use stream_id for internal data structures.
This fixes the most core data structures inside of
muting.js.  We still use stream names for incoming
data to set_muted_topics and outgoing data from
get_muted_topics.

This will make us more resilient to stream name changes.
Before, if you were logged on when a stream rename
occured, topics that were muted under that stream would
appear to be unmuted.  (You could fix it with a reload,
but it can be jarring to have a bunch of unread messages
appear in your feed suddenly.)

Fixes #11033
2018-12-14 15:58:35 -08: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 2fac1fe6c9 node tests: Use zrequire in muting.js. 2017-11-08 12:24:17 -08:00
Steve Howell 7d153c9f8a Revert "muting.js: Track muted streams using stream id."
This reverts commit c7f710b8d4.

Because the back end still stores muted topics fundamentally using
stream name as a key, trying to cut over the client to use stream
id was just making things more brittle.  Mutes would work after
renaming the stream, which was progress in the change that we
revert here, but only until page load.  The other problem, which
is more severe, is that the order of page loading functions would
cause no mutes to happen at page load time.  This could be fixed
to some degree, but we should do a deeper fix on the back end.
2017-05-17 07:06:32 -07:00
Steve Howell c7f710b8d4 muting.js: Track muted streams using stream id.
This should prevent some glitches with stream rename events.
2017-05-15 14:47:41 -07:00
Rishi Gupta ddd0b854f9 Remove references to page_params.domain.
Continuation of 098797c, which removed the page_params.domain field.
2017-03-14 17:17:42 -07:00
Elliott Jin d233f617dd muting: Refactor to move side effects into UI layer. 2017-02-11 08:36:39 -08:00
Elliott Jin 0e0584aeaa muting: Fix calling update_unread_counts in a loop.
Previously, set_muted_topics was calling update_unread_counts once for each
topic in the input; this results in poor performance when there is a large
number of muted topics.

Fixes: #3605
2017-02-08 11:13:19 -08:00
Tim Abbott 459421d045 eslint: Update node tests to use new comma-dangle rules.
* In most cases, eslint --fix with the right comma-dangle settings was
  able to update the code correctly.

* The exceptions were cases where the parser incorrectly treated the
  arguments to functions like `assert_equal` as arguments; we fixed
  these manually.  Since this is test code, we can be reasonably
  confident that just fixing the failures suffices to correct any bugs
  introduced by making changes automatically.
2016-12-03 15:00:24 -08:00
Kartik Maji 2b3312cd6e Update unread counts for streams when muting topics.
Fixes #427.
2016-03-27 13:49:52 -07:00
Tim Abbott 10657c1d53 Move node tests to node_tests/. 2015-10-28 10:11:47 -07:00