Commit Graph

120 Commits

Author SHA1 Message Date
Leo Franchi 8b1f0223fe Update the dom_id of message objects when their id changes
(imported from commit e766eff7d966d95616ac192c8cb0cb328bd96b1b)
2014-03-14 20:48:50 -04:00
Leo Franchi 7f3ea34dc5 Make sure to re-select selected after re-ordering
(imported from commit 50878874372d1304014f5285b488db6ab896abbd)
2014-03-14 20:48:49 -04:00
Leo Franchi e7c8c322c0 Handle case where _lower_bound returns size of input list
(imported from commit bd91512615b11935eafd5809ca414eeb0cf189c4)
2014-03-14 20:48:49 -04:00
Leo Franchi 065fcf1a1b Handle out-of-order local ids in message_list
(imported from commit e805837d7d2790be90490cc9ec9415882ff9b549)
2014-03-14 20:48:47 -04:00
Leo Franchi 7cd814d92c Keep track of local ids in our message list
(imported from commit d96eaa14bf9f4b315d6893e6cd6c8d3c069c1d14)
2014-03-14 20:48:46 -04:00
Jason Michalski 09dfc9a89b Split selecting a message and hiding the empty narrow message
We should hide the empty narrow message message whenever the narrow is
not empty, but we should only select a message if non are currently
selected.

(imported from commit 22f6b0827dc84ed587a83b5d713b12c1d5d4c0a0)
2014-03-04 16:43:00 -05:00
Leo Franchi 5aef8b8fad Maintain scroll position when removing selected message
(imported from commit 1021eac527e677fbcac46d0a7d44dd3244bb903e)
2014-02-27 20:25:32 -05:00
Leo Franchi 240050093b Preserve scroll when rerendering due to out-of-order messages
(imported from commit 9c339cbe8d5bbd75bbdf24a8f14da4f1556cc407)
2014-02-27 20:25:31 -05:00
Leo Franchi 568c33f294 Render messages as groups of divs instead of individual rows
Now that we no longer use tables for our message list, we can
more logically group messages together.

(imported from commit 9923a092f91a45fe3ef06f2f00e23e4e3fb62a37)
2014-02-27 20:25:23 -05: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 174a62eb7c Remove requirement of no selected id to hide empty feed message
(imported from commit 10f4882a5f2def7e5b8567942758bb33007601d0)
2014-02-27 20:25:23 -05:00
Tim Abbott 1bd9e5809c Restore the browser's scroll position on server-initiated reload.
(imported from commit 934659c0f1a2c014cfd2811fe49ea31abad262b2)
2014-02-06 10:25:35 -05:00
Tim Abbott 7e6bb801e2 Move message_range to a function on the message list.
(imported from commit c78710a3ccddb15352086b450fb6986e1251f364)
2014-02-03 13:32:02 -05:00
Leo Franchi f528ac659d Only attempt to reorder a message if we had it in the message list originally
(imported from commit 0b2802c1f1b6b17cd9f52dd9cecdf84f6f1cf5b0)
2014-01-24 14:01:18 -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
Tim Abbott 09dbaabcb6 Update unread flags between multiple browser windows.
(imported from commit 1c5e2bc0233c28c72ce4c8253fa0717ae4793f84)
2014-01-23 13:21:59 -05:00
Leo Franchi 685ab1a583 Add message_list.remove_and_rerender
(imported from commit 68da0ad74f797fae3257577bbf415fd1fe9488a6)
2014-01-07 17:33:33 -05:00
Leo Franchi 80e6dab78a Parse message IDs as floats
(imported from commit d9954e4225e95e2931be1d1fe5ecf0b93914b07e)
2014-01-07 17:33:33 -05:00
Tim Abbott 73643acd03 Fix muting the last stream in the home view.
(imported from commit b35e9903cdb8697a1010147854feb13060e9516d)
2013-12-18 14:30:17 -05:00
acrefoot 06c689738e Show @-mentioned messages even for muted topics
This addresses Trac #1929

(imported from commit 1b30ee7ae602e83f5977ffd4f32e478f719683d1)
2013-12-09 20:09:11 -05:00
Jessica McKellar 7c9e7e57b9 Remove message_list:get_messages, which is redundant with all().
(imported from commit 100eb775b89c54c45f70cf903018bdaefa99d3f6)
2013-12-09 10:41:26 -05:00
Steve Howell 00946f97df Log more data for "Cannot select id -1".
Show the incoming id and the length of this._items.

(imported from commit 106dda862918a4f40481a5692cbfee1738218150)
2013-12-02 15:45:40 -05:00
acrefoot 9e50781131 Random javascript shortenings
(imported from commit 68a34d67ac38e34035a3e3986518824bf5a96fc5)
2013-11-13 16:41:36 -05:00
Zev Benjamin 3f0fa363f9 Add explanatory comment
Leo and I were looking over this code and I couldn't remember what it
was doing.  So after I re-derived its purpose, we figured that an
explanatory comment was in order.

(imported from commit ce984362e2b504b40f3d3586777bd73691ad5ea7)
2013-11-12 15:32:09 -05:00
Kevin Mehall d93c7545f6 Revert rendering window changes related to summarization
This reverts commit c10d9c1a0d23891acce88bf8d79866c08cb75681.
This reverts commit 9259a246946cd968a8725c38ff5ef2d4b4793717.

(imported from commit 50e9e0136c2487cc63d75ae2b78df0c70a1b0be1)
2013-11-07 11:04:27 -05:00
Zev Benjamin d5b7cfd21a Fix whitespace
(imported from commit 095ea8640a18560aae7bd5e045c4f68c96f96f73)
2013-10-30 15:52:35 -04:00
Zev Benjamin eb7fd1ba51 Add some front-end debugging changes
(imported from commit 21684b09100bc0a24372948a9417c973709c1be2)
2013-10-30 15:52:35 -04:00
Kevin Mehall bd58861b09 Ignore summarized messages when calculating rendering windows.
Summary blocks can contain hundreds of messages. When the rendering window
code didn't take this into account, it would lead to all kinds of
unpleasant behavior when you scroll.

Trac #1888

Unfortunately, this replaces a subtraction with a function that iterates
through all the messages.

(imported from commit 9259a246946cd968a8725c38ff5ef2d4b4793717)
2013-10-21 11:48:57 -04:00
Kevin Mehall a528b7134c Move summary_adjective to its own method
(imported from commit d451ffcf3ff460ffe030e265ca83fec1094c6217)
2013-10-21 11:48:56 -04:00
Steve Howell ec1c82d6d7 Select closest id in MessageList.rerender().
When we call rerender() on MessageList, it is usually because
something big has happened, so it's reasonable that the pointer
may now be invalid.  As an example, the old pointed-to message
may been removed from the home view.  We have always just
moved the pointer under the hood, but now we do it in a way
that doesn't generate spurious blueslip errors.

(imported from commit d399a101f36b744a423ea7da80dda8352440c6c9)
2013-09-30 16:18:18 -04:00
Steve Howell f67acb3157 Filter duplicate messages more aggresively.
This fixes a blueslip error where we were trying to add the same
message into a MessageList twice.  Muting complicates our duplicate
detection, because empty() can return true even when we already
are storing messages that just aren't shown (because of muting).

The name empty() should probably be fixed in light of muting,
but filtering with self.get() is not really a problem here.

(imported from commit 83b0890471c9a0aa21996f3d0d3be4a238f23e65)
2013-09-28 15:48:38 -04:00
Steve Howell ea7fda59d3 Reset _all_items in MessageList.clear
(imported from commit 3e319578500480ebfe0da6c4541628a61f8b5ff9)
2013-09-28 15:48:37 -04:00
Steve Howell c79e3a95b1 Avoid selecting hidden message ids.
With the muting/hiding features, it has become the case that
this._hash can have entries that don't map to actually visible
rows, so this.get() can return true on an id that shouldn't
actually be selected, causing downstream code to explode.  Now
we call this.closest_id() regardless of whether the hash is
populated, to be safe, but then we still call blueslip.error
if the pointer moved.

(imported from commit 348e8ff67ce3a6d61aaeb31f80549386518af2d0)
2013-09-28 15:48:36 -04:00
Steve Howell 660475bd0c Hide muted messages.
Instead of collapsing muted messages, just hide them altogether
in view where it makes sense to hide them.

(imported from commit 1c2c987ff302ceb135a025753cf421b4de1aea71)
2013-09-23 10:53:06 -04:00
Steve Howell 6c6816491d Add muting_enabled option to MessageList.
(imported from commit c86772b7dea864c49091c988772e17aae5efa5bc)
2013-09-23 10:53:06 -04:00
Steve Howell 21b30664b6 Create MessageList.add_messages() from zulip.js code.
I moved code into MessageList to further encapsulate details
of filtering.  The MessageList instances should be their own
gatekeepers for what messages they care about.

(imported from commit ee6cd7f6eabf97962d724a05d7d0b0a3e6ab19e5)
2013-09-22 14:35:53 -04:00
Jessica McKellar 081ae7771a Add a MessageList method to update message recipients.
(imported from commit 3c24f045aa5726fcab8b9acd91105044e7783b63)
2013-08-28 10:23:39 -04:00
Steve Howell 579444eee2 Enable "enter" key for muted summary rows.
(The approach has been simplified to look for summary_row in
the DOM, which makes muted and summary features work off the
same code.)

(imported from commit 4fa3d6ae5ad7bbac5958e60ecffb368d6ef29d2e)
2013-08-23 15:52:08 -04:00
acrefoot 395aaae994 Allow anyone to edit a "no topic" message
This change would allow anyone in the realm to set a topic for a "no topic"
message. As soon as the message topic is set, only the sender can change it again.

(imported from commit 0a91a93b8fd14549965cedc79f45ffd869d82307)
2013-08-19 16:29:30 -04:00
Steve Howell 53f62bd71c Created MessageListView class.
(The code for MessageListView  was extracted from message_list.js.)

(imported from commit 60c0bac4c734d3850f8b8c047a978c292b19cc13)
2013-08-19 12:17:56 -04:00
Steve Howell 29c012dc74 Create stream_data.js module.
This pulls a lot of data-centric functions out of subs.js.

(imported from commit 0deed7d4bf5697e893af9bc9d888c2d5da8d9fa2)
2013-08-19 12:17:55 -04:00
Steve Howell ecb3399a8d Move summary exemptions from 5 to 8.
(imported from commit 279422ffb9e6d826a9e70e577fe334631f2697ca)
2013-08-15 11:03:26 -04:00
Steve Howell 75ffd4d637 Exempt last 5 messages in view from summarization.
Once you enter a view, the last n messages will be exempt from
summarization, to give the users a little more context.  Any
subsequently arriving messages will also be exempt.

We will try n=5 at first.

(imported from commit 3e6fe58109e692389bf02dde2230d788b5818d52)
2013-08-15 08:20:29 -04:00
Steve Howell 3e1cdaaded Add MessageList.nth_most_recent_id().
(imported from commit 69a424d4990402b9e77fbfa57fa573a002cf04ce)
2013-08-15 08:20:29 -04:00
Kevin Mehall de58b3fb4c Instead of DOM lookups, implement get_row in O(1) with a map updated after rendering.
(imported from commit 52927e87463e49f9f4522baa065cc934094f58de)
2013-08-14 17:08:47 -04:00
Kevin Mehall 0f6c7ca7be Use msg_list.get_row(id) instead of rows.get(id, msg_list.table_name)
(imported from commit 953cd24e605269d2bbdc42b878506f0ab01501e8)
2013-08-14 17:08:32 -04:00
Steve Howell 4b0cef8a83 Fixed code comments
(imported from commit 75b0ad464bab2e9b0b24f7c6a484b9c99d8b5a7a)
2013-08-14 13:22:28 -04:00
Steve Howell 59b84aad4a Properly fade recipient bar of incoming messages.
This fixes #1682, a recent regression that came out of
a5a47e13fc9d, which introduced the update_rendered_messages()
function in compose_fade.js.  The original implementation
was finding the table row for a message, but not the table
row for its recipient bar.  Now we style both elements.

(imported from commit a9628df0b03f79a24dfa68f4f2061eda2ca8ecea)
2013-08-14 13:20:39 -04:00
Steve Howell beb89e247f Avoid unnecessary fading/unfading processing via message_list.
The call to compose_fade.update_faded_messages() in message_list
caused us to traverse every message in the current table, which
was extremely inefficient.  Now we call the newly created
compose_fade.update_rendered_messages(), which only fades/unfades the
messages passed in as the first parameter.

(imported from commit a5a47e13fc9daeedd0899b2cfb02beb3f6b8cd0a)
2013-08-13 17:14:06 -04:00
Waseem Daher 067bd390ac Remove kiosk mode.
We instead implemented the ~desired functionality here using the
API and a bot to make a totally read-only, static, slowly-updating
view into the Zuliverse.

This is the moral equivalent of reverting deb035b4c702fcdb0e660ed549fe74c682abb6d9

(imported from commit 9d743fe82f197b37f005e5a038f77cc4b8566024)
2013-08-12 16:19:53 -04:00
Steve Howell 878ee2b3fd Move Filter class to filter.js from narrow.js.
1) The class Filter now lives in its own module.
2) The function canonicalized_operators() is now a class method on Filter.
3) The function message_in_home moved to filter.js and became private.
4) Various calling code had to change, of course.
5) Splitting out Filter helped simplify a few tests.

(imported from commit e41d792b46d3d6a30d3bd03db0419f129d0a2a7b)
2013-08-12 13:58:32 -04:00
Steve Howell 37f8cc9294 Extracted code into compose_fade.js.
The compose_fade has three public exports:

    set_focused_recipient
    unfade_messages
    update_faded_messages

All code was pulled directly from compose.js, except for the
one-line setter of set_focused_recipient.  The focused_recipients
variable that used to be in compose.js was moved to compose_fade.js,
hence the need for the setter.

(imported from commit 462ca5d0d0bd58612d0197f3734a8c78de8c6d30)
2013-08-11 17:05:13 -04:00
Waseem Daher 0dcaf9ca3d Kiosk mode [unsafe].
"Kiosk mode" is a "read-only" Zulip suitable for embedding into
an iframe on another site. I say "read-only" in quotation marks,
because the account is still a fully-fledged active account on
the server, and we just tear out a bunch of stuff in Javascript
(that a malicious user could easily re-enable).

So in that sense, it's not actually safe in security-sensitive
environments -- malicious users logged in via kiosk mode
can do anything the kiosk-mode user can do.

(We need this functionality for the customer3 realm specifically;
 we'll possibly just tear this code back out once that experiment
 has run its course.)

(imported from commit deb035b4c702fcdb0e660ed549fe74c682abb6d9)
2013-08-11 15:57:21 -04:00
Waseem Daher 1f80302668 Use 12-hour time (with some exceptions).
(imported from commit 0cb3cfe23c8696368e3dc8ac51eaa5419928f6f5)
2013-08-09 14:32:02 -04:00
Steve Howell e36fd929bc Created stream_color.js.
This is a pure refactoring that mostly just moves code from
subs.js to the new stream_color.js and updates module references
accordingly.  In order to prevent introducing some exports,
update_stream_color was given an additional "sub" parameter
and update_stream_sidebar_swatch_color was given an "id"
parameter.

Killed off unused initial_color_fetch var.

(imported from commit b7644ce67f50d31fb46f564d758d661eea776aa6)
2013-08-08 18:22:44 -04:00
Kevin Mehall 2dfcd7876d Copy only specified properties from messages to summary row fake messages.
See previous commit message for why.

(imported from commit 53241f3aab3ec48a90cd9a280a0e5ec4a19e33cd)
2013-08-08 17:54:52 -04:00
Kevin Mehall 9be559858e Summarization style improvements
(imported from commit 4029d96d60cae0c6856067a696a842c39f4248e3)
2013-08-08 13:04:01 -04:00
Kevin Mehall e03f3dabc1 Make Enter on a summary row expand it.
(imported from commit 4ad44a96a225f6cfbb7d4f62ebf7c62298dd730b)
2013-08-08 13:04:01 -04:00
Kevin Mehall 2664002dec Make summary rows selectable.
We represent summary rows by the ID of their first message for
for selection purposes.

(imported from commit 9f3c4d23f6b1295b117d5197e214de983bb2cc20)
2013-08-08 13:04:01 -04:00
Kevin Mehall 0b9497305f Add defensive checks against undefined messages to _is_summarized_message.
Should fix the issue with empty realms.

(imported from commit afca70ebf3b7b74ae0d0c269c72b4f8d54fc254b)
2013-08-08 12:47:23 -04:00
Kevin Mehall eb2e8a15c3 Fix "Selected message id not in MessageList" caused by summarization.
Summarized messages are not shown and cannot be selected. If
`opts.use_closest === false` and you try to select a summarized
message, we still have to use the closest instead of failing.

Eventually, we'll make summary rows selectable, but that would be
rather involved since selections are managed by ID, summaries exist only
in the DOM, and many parts of the code get the selection and expect
it to be a message.

(imported from commit 998c4f24aece84528cc9da53a47f9e4f5391702d)
2013-08-07 15:07:47 -04:00
Kevin Mehall eac6463031 Implement message summarization experiment.
When you read messages in a narrow and then un-narrow, collapse
adjacent messages read in the narrow into a summary row that can
be clicked to expand those messages.

Scoped to staging with feature flags.

The implementation of this within our current MessageList is rather ugly.

(imported from commit bcb3a39d8c0c334136fe86318f18ead03f0f50bf)
2013-08-07 10:24:03 -04:00
Steve Howell 57f518c9c2 Add node JS unit tests for MessageList.
(imported from commit 486a343add91fd5037431504e1ce4a750bfa9fbf)
2013-08-07 09:25:13 -04:00
Tim Abbott 5a320db3c1 Add curly braces for all javascript if statements lacking them.
(imported from commit 32c7643d1a6ecdfaf634424d217938c8a368dade)
2013-08-01 11:47:54 -04:00
Kevin Mehall 112d37de86 Fade message dots faster when marked read by cursor.
(imported from commit a31b0601bf13bce377c24fff96a818023d5bdd1f)
2013-08-01 11:26:55 -04:00
Scott Feeney a35fff90cc Replace $.extend
(imported from commit 2c1ee3c2714d388f2a71398fe81c049cc54ff94d)
2013-07-30 12:12:59 -04:00
Scott Feeney 8703134a23 Replace $.each with _.each
In a few cases the $.each was doing something imperatively that was
terser and easier to understand by using a different Underscore method,
so a few of these I rewrote.

Some code was using the fact that jQuery sets `this` in the callback to
be the item; I rewrote those to use an explicit parameter.

Some code was using $(some selector).each(callback). I converted these
to _.each($(some selector), callback).

One function, ui.process_condensing, was written to be a jQuery $.each
callback despite being in a totally different module from code using it.
I noticed this and updated the function's args.

(imported from commit bf5922a35f257c168cc09ec1d077415d6ef19a03)
2013-07-30 12:12:58 -04:00
Tim Abbott bc4d7c687d Rename our custom JS events to use Zulip, not Zephyr.
(imported from commit 61ac456d394a6dbc14f3e9183a53313990db5059)
2013-07-29 12:11:26 -04:00
Tim Abbott 3bba0cc927 Move zephyr/static to just static.
It's not really a part of the server (aka the rest of zephyr/).

(imported from commit 27f6b6b064938ad927075a68d873e4b68710d279)
2013-07-29 12:11:26 -04:00