Commit Graph

6131 Commits

Author SHA1 Message Date
Steve Howell d2ee76896c Extract local_message.js.
We will eventually want these functions to support things
other than local echo, such as ephemeral messages from chat
bots.
2018-05-16 09:30:49 -07:00
Steve Howell e3b119c010 Add people.safe_full_names. 2018-05-16 09:30:49 -07:00
Yashashvi Dave b949d10592 /json/bots: Replace email with user_id in API to generate bot_api_key.
Fixes #3643.
2018-05-15 16:37:06 -07:00
Yashashvi Dave d6e2f9fc88 /json/bots: Replace email with user_id in API to update bots. 2018-05-15 16:34:17 -07:00
Tim Abbott 3e04aa99fa fonts: Use source-sans-pro CSS from upstream. 2018-05-15 16:22:44 -07:00
Aman Ghebreweldi b496afc8b9 third: Remove font Source Sans Pro from static/third.
We can just get it from NPM instead.
2018-05-15 16:22:44 -07:00
Tim Abbott 785d615921 ui: Remove do_stuff_for_desktop_app call.
Apparently I missed this when removing the code for the old desktop
app.
2018-05-15 16:22:44 -07:00
Tim Abbott 1188f4a3e3 notifications: Remove remaining basic window.bridge logic. 2018-05-15 16:00:30 -07:00
Tim Abbott 954fd8178f desktop: Remove logic for legacy QT/webkit desktop app.
We leave around a few comments that may help the new electron desktop
app do similar things in the future.
2018-05-15 16:00:14 -07:00
Steve Howell 9eb3bdaf6c page load: Make initializations more explicit.
We now initialize most modules in ui_init.js, which
isn't the perfect place to do it, but at least now
we have a mostly consolidated entry point.

All the new foo.initialize() methods introduced in
this module run the same order relative to each
other as before this commit. (I did some console
logging with a hacked version of the program to
get the order right.)  They happen a bit later than
before, though.

A couple modules still have the `$(function() {`
idiom for miscellaneous reasons:

       archive - is a different bundle
       common - used elsewhere
       list_render - non-standard code style
       scroll_bar - no exports
       setup - probably special?
       socket - $(function () is nested!
       transmit - coupled to socket
       translations - i18n is a bigger problem
       ui_init - this bootstraps everything
2018-05-15 15:46:04 -07:00
Steve Howell c7731a7ebb Move functions into ui.initialize().
We had three different initialization entry points
for ui.js, which seems a bit excessive. :)
2018-05-15 15:43:55 -07:00
Steve Howell b8f12728bc Rename invite.initialize() to invite.launch().
We generally want initialize() functions to only run
once at startup, whereas launch() is consistent with
other modals.
2018-05-15 15:43:55 -07:00
Steve Howell ad6de6e268 message_list: Remove unused delay_render option. 2018-05-15 14:25:21 -07:00
Steve Howell 8cb383223d Defer creating messages lists in narrows.
We now work with MessageListData objects while populating
data from local narrows, before actually making the
wrapper MessageList object.

This change will simplify unit testing (less view stuff
to fake out) in certain situations.

It will also allow us to eliminate the delay_render flag.
2018-05-15 14:25:21 -07:00
Steve Howell ff009fadf9 refactor: Have MessageList take in a data object.
We now allow you to initialize a MessageList with
a MessageListData object that you build outside of
the initializer.
2018-05-15 14:25:21 -07:00
Steve Howell a3d3d08a80 refactor: Avoid positional params for MessageList.
We used to have positional parameters for table_name
and filter, but we don't use them for message_list.all
and we're about to replace filter in some cases.

Passing everything in on opts is more consistent and
self-documenting in the calling code, plus lots of
unit tests can get away with passing in `{}` now
for situations where table_name does not matter.

All of our callers pass in muting_enabled, so we
remove the default value for it.  And then the
collapse_messages variable doesn't have to live on
`this` as it's only being passed through down to the
view.
2018-05-15 14:25:21 -07:00
Steve Howell f61ecef138 refactor: Cleanly divide data/view for add_messages.
Before this change, the way to add messages had a lot
of ping-pong-ing between MessageList and MessageListData,
where first the data got triaged, but not actually
inserted into data structures, and then subsequent
calls would add the data and get filtered results.

Now we have a simple API for MessageListData.add_messages
that does all the data stuff up front.  Having a fully
function MLD.add_messages not only makes the ML.add_messages
function about four lines shorter, it also sets us up
to easily build standalone MLD objects before making
the heavier ML objects.
2018-05-15 14:25:21 -07:00
Steve Howell 467fe7ceec refactor: Extract message_list.append_to_view. 2018-05-15 14:25:21 -07:00
Steve Howell 56f872507c refactor: Inline message_list.prepend. 2018-05-15 14:25:21 -07:00
Steve Howell 6834745feb refactor: Inline message_list.add_and_rerender. 2018-05-15 14:25:21 -07:00
Steve Howell 08fd2027a1 Refine offset logic for narrows.
We now only preserve the offset for the previous
selection (pre-narrow) if that is still the id
we want selected after calling maybe_add_local_messages.

Right not this does not change any behavior, but
upcoming changes to maybe_add_local_messages will
change the selected id to the first unread message
in certain circumstances, in which case preserving
the offset will possibly be confusing, since you're
not on the same message.
2018-05-15 14:25:21 -07:00
Steve Howell 0dea143fcf Use unread data in topic_data.get_recent_names().
Fixes #9347.
2018-05-15 14:25:21 -07:00
Steve Howell 9b4a4d09ea Add unread.get_missing_topics().
We will need this for cases where the topic names in
unread.js are a superset of the names we got from messages.

It's important to pass in a dict of existing dicts to avoid
expensive max() calls to get the max ids of topics (otherwise
the plan would have been to merge the lists in the caller).
2018-05-15 14:25:21 -07:00
Yashashvi Dave d66d2445b4 custom fields: Don't ask org admin to enter "value" for choice.
When org admin add choice type of custom profile fields, set
numeric ID for choices instead of asking "value" from org admin.
2018-05-15 12:08:29 -07:00
Yashashvi Dave ece6b68e4c custom fields: Remove minor bugs in custom profile org settings.
Remove minor bugs like reset create-field form, on submit.
Set initial true values in edit-field form.
2018-05-15 12:08:29 -07:00
Yashashvi Dave ffe986886f custom fields: Fix field value not saved on change, just after created.
Whenever custom fields templates get rendered within user account
settings, on-change event listener wasn't get created. Cause
event listener wasn't set properly.
2018-05-15 12:08:29 -07:00
Alena Volkova ba9668470c emoji: Don't start typeahead for colon-space.
Fixes #9339.
2018-05-15 11:18:08 -07:00
Yago González 35577a1f66 api docs: Rename Swagger directory to OpenAPI. 2018-05-15 11:05:03 -07:00
Yashashvi Dave 80beb51836 edit bot: Fix error on updating no-owner-bots name.
When org admin tries to change only bots name of no-owner-bot,
It update bots name but returns error, "No such bot owner".
Cause frontend pass `null` value in `bot-owner`.
2018-05-15 10:35:19 -07:00
Yashashvi Dave 0554e68528 static/templates/edit_bot.handlebars: Fix undefined bot_id.
Template was rendering undefined value of `bot_id` instead of
`user_id`.

Fix this by replacing `bot_id` with `user_id` and changing
template data variable to `data-user-id` to avoid
future confusion.
2018-05-15 10:35:19 -07:00
Shubham Padia f0d874d51f hashchange: Handle trailing slashes in narrowing URLs.
Fixes #9305.
Empty operators are not allowed while parsing narrowing URLs.
`parse_narrow` stops parsing further if it encounters an empty string
operator.
2018-05-15 09:34:50 -07:00
Aman Ghebreweldi 83ee8211a8 third: Get sorttable package from npm.
We didn't have any local changes, so there's no need to have it
vendored in the repository.
2018-05-15 09:25:48 -07:00
Tim Abbott dc7f6c8a48 bots: Fix incorrect maximum lengths for outgoing webhook URLs.
2083 is the correct maximum length for a URL.
2018-05-14 10:42:23 -07:00
Yago González 7ae51a4ec6 docs: Update API key-related screenshots. 2018-05-13 15:02:48 -07:00
Steve Howell b5904b264d minor: Pull statements out of loops in unread.js.
We were recalculating the same sub for every iteration
in these two loops.  It's a pretty fast operation
but still nice to do only one time.
2018-05-13 08:47:55 -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 6ca145b2ed Add unread.get_all_msg_ids(). 2018-05-13 08:47:55 -07:00
Yago González 184bd8304e i18n: Tag missing strings for translation. 2018-05-12 16:44:56 -07:00
Max Nussenbaum bf27ed2b1b portico: Swap annual and monthly pricing on plans page.
This swaps the annual and monthly pricing on the plans page
(with the .67 cents properly aligned).
2018-05-12 15:29:28 -07:00
Max Nussenbaum fc6833e46a portico: Add quote to Why Zulip page.
Adds a quote from Grahame Grieve to the Why Zulip page.

With tweaks by tabbott to make the linter pass.
2018-05-10 14:17:21 -07:00
Tim Abbott 4abbfe9154 people: Fix issues with client_gravatar and upper-case emails.
We weren't properly canonicalizing user email addresses when consuming
gravatar URLs.

See http://en.gravatar.com/site/implement/hash/ for the specification.

Fixes #9357.
2018-05-10 12:35:20 -07:00
Max Nussenbaum 39e461a31b portico: Improve readability of FAQ on Plans page.
This restyles the FAQ text on the Plans page to match the recent
changes on the Why Zulip page: narrower text width and increased
contrast.
2018-05-10 07:34:35 -07:00
Max Nussenbaum 49ee6e65c2 portico: Improve readability on Why Zulip page.
This increases the font size, decreases the paragraph width, and
makes the text darker on the Why Zulip page to improve
readability.
2018-05-10 07:34:35 -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 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 9b15c2cd46 minor: Re-order code blocks.
This is setting up for a subsequent commit to have a smaller
diff.  The current ordering of the code blocks doesn't matter,
since only one of the conditions will be true, so this won't
change any behavior.  (Later commits will make the order matter.)
2018-05-10 06:36:13 -04:00
Steve Howell 19ac0b23ab Add filter.can_bucket_by(). 2018-05-10 06:36:13 -04:00
Tim Abbott c7b44d44e4 third: Remove now-unused LazyLoad library.
We don't reference this anymore (it was only ever used by the Dropbox
integration, which was hardcoded-off for years before being removed in
e6833b6427)
2018-05-08 14:38:27 -07:00
Steve Howell ea581c546c Add filter.is_valid_id_from().
We will use this to find the first id from a list of
message ids that matches a filter.  (This will help us
during narrowing to determine whether we have at least
one good message locally, so that we can render something
useful before waiting for the server.)
2018-05-08 12:13:55 -07:00
Steve Howell a176380df5 refactor: Introduce filter.is_exactly().
This new API replaces some more specific functions that were
only recently introduced:

        is_stream_only
        is_stream_topic_only
        is_pm_with_only
        is_for_only

We use the deterministically sorted "term_type" values for
matching.  (Notably "stream" will come before "topic".)
2018-05-08 12:13:55 -07:00