Commit Graph

64 Commits

Author SHA1 Message Date
Anders Kaseorg 674abdef43 drafts: Fix CSS transition when opening drafts.
The code was all there, but we weren't triggering a style calculation.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-03-07 20:55:02 -08:00
Steve Howell cdce66813e drafts: Fix date-sensitive test.
To test formatting we want a hard coded date, so we
can verify the date arithmetic with stable dates.

To make the test less brittle, we disable the
feature to remove old drafts.

This was an emergency fix.  We should probably just
remove the last N drafts instead of having the 30-day
limit.  Or we should have a better way to stub the cutoff
date.
2019-02-20 06:49:19 -08:00
Vaibhav 2ca8ec371e drafts: Change foreground for dark background streams in drafts modal.
In drafts modal, dark background streams still had black foreground;
This changes the foreground to white for the same.
2019-02-14 11:32:11 -08:00
Vaibhav 72bd3d22e8 drafts: Add helper functions to get focused draft rows.
Adds three helper functions - `row_with_focus`, `row_before_focus` and
`row_after_focus` to get the focused, previous and next to focused
draft rows respectively.
2019-02-13 16:16:34 -08:00
Vaibhav e0134111d5 drafts: Rename `delete_id` to `draft_to_be_focused_id`.
`delete_id` in `drafts.js` referred to the next draft row which was
to be focused when deleting using hot keys. The var name was absurd
and is hence renamed.
2019-02-13 16:16:34 -08:00
Vaibhav 69424e4f2f drafts: Refactor code used to remove drafts.
Adds a `remove_draft` function which deletes the draft and updates the ui
by removing it from the list of drafts.
Also adds comments to increase readability.
2019-02-13 16:16:34 -08:00
Steve Howell c4cd0fe0c1 drafts: Use a reverse-cron sort.
I think it's natural for your eyes get drawn to
the top of the modal, so that's where we should
put the most recent draft.
2019-02-13 16:16:34 -08:00
Steve Howell 7d23076a0e drafts: Fix bug in finding current element.
We weren't using the actual sorted data to find
the last element.  This probably worked by accident
in some cases, but this commit makes it more
deterministic.
2018-12-16 15:46:41 -08:00
Steve Howell ebd6d84326 refactor: Call format_drafts() more directly.
We want the return value from this for the next
commit, so we no longer call `format_drafts` indirectly
from `populate_and_fill`, and we rename the latter
to `render_widgets`.
2018-12-16 15:46:41 -08:00
Steve Howell 1584789916 refactors: Move format_draft() to module level.
This is a pure code move.
2018-12-16 15:46:41 -08:00
Steve Howell e22a50a3e3 drafts: Use lists instead of dicts.
We were using a dict to return a sorted list of
formatted drafts, instead of building a list.
2018-12-16 15:46:41 -08:00
Steve Howell 29052b36a5 minor: Rename last_draft -> curr_draft. 2018-12-16 15:46:41 -08:00
Steve Howell c82233c435 drafts: Avoid callback mechanism.
We had an anonymous callback for drafts that was
hard to read.  It's much easier to flatten the code,
give functions actual names, and stub them as needed
in the unit tests.
2018-12-16 15:46:41 -08:00
Steve Howell 840210a0ba minor: Move setup_event_handlers() in code.
We place this code under populate_and_fill().

And instead of calling this at the end of
populate_and_fill(), we call it AFTER
populate_and_fill().
2018-12-16 14:38:28 -08:00
Steve Howell e38496ddc0 drafts: Show active element clearly. 2018-12-16 14:38:28 -08:00
Steve Howell 35b904b184 subject -> topic: Fix subject in opts.
It's kinda difficult to track down all the interactions
with the opts that go through compose_actions.start(),
but I think I got everything.
2018-12-16 11:26:18 -08:00
Steve Howell 9861cdfeb6 drafts: Use "topic" internally.
We still have to support "subject" for old drafts,
but we write "topic" for new drafts.
2018-12-16 11:26:18 -08:00
Steve Howell 9ba7b4fcbb drafts: Extract drafts.restore_message().
We make our deep-copy more explicit, change
the var name from draft_copy to compose_args,
and clean up some code formatting.
2018-12-16 11:26:16 -08:00
Steve Howell d7aa5fcc38 compose: Remove obsolete references to replying_to_message.
The `replying_to_message` field was used in some
early versions of compose fade, but it has no more
use in the current code.

The drafts implementation didn't really make any sense,
anyway, as we were claiming to reply to the same
message we were drafting.
2018-12-16 11:26:02 -08:00
Tim Abbott 838dd6d273 lint: Add eslint enforcement for comma-spacing.
We've been enforcing this manually for a long time, and hadn't
realized it was missing from our eslint configuration.
2018-12-07 12:22:24 -08:00
Rohitt Vashishtha d7a0bd4a6c subject-to-topic: Add topics to compose_state.js. 2018-11-14 23:24:06 -08:00
Joshua Pan eca4266cde drafts: Don't save drafts with 2 or less characters.
Fixes #10357.
2018-08-22 16:52:18 -07:00
Armaan Ahluwalia 6d255efe4c app: Prepare JS files for consumption by webpack.
This commit prepares the frontend code to be consumed by webpack.

It is a hack: In theory, modules should be declaring and importing the
modules they depend on and the globals they expose directly.

However, that requires significant per-module work, which we don't
really want to block moving our toolchain to webpack on.

So we expose the modules by setting window.varName = varName; as
needed in the js files.
2018-07-05 10:53:36 +02:00
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -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
Shubham Dhama cc03f9fb8f eslint: Enable space-infix-ops rule.
More about rule at  https://eslint.org/docs/rules/space-infix-ops
2018-06-05 00:47:35 +05:30
Tim Abbott a087b34f12 drafts: Eliminate now-unnecessary ensure_i18n. 2018-05-30 09:06:13 -07:00
Tim Abbott 063d11b139 js: Standardize indentation of switch/case statements.
This gets my current draft eslint indentation configuration passing
cleaning on static/js.
2018-05-06 19:35:18 -07:00
Tim Abbott 7ab8a8e820 js: Fix a bunch of indentation issues found by eslint.
This is preparation for enabling an eslint indentation configuration.
90% of these changes are just fixes for indentation errors that have
snuck into the codebase over the years; the others are more
significant reformatting to make eslint happy (that are not otherwise
actually improvements).

The one area that we do not attempt to work on here is the
"switch/case" indentation.
2018-05-06 16:25:02 -07:00
Tim Abbott e4c50ff4fd narrow: Remove unnecessary select_first_unread option.
We consistently either pass a `then_select_id` into narrow.activate,
or were using the select_first_unread option.  Now, we just compute
select_first_unread based on the value of then_select_id.
2018-04-22 21:33:33 -07:00
Shubham Dhama 5a9b1f863f drafts: Fix same day's timestamp when language is other than english. 2018-03-14 10:57:11 -07:00
Shubham Dhama 7aeae688e7 compose: Remove draft older than 30 days.
This removes drafts older than 30 days as they become irrelevant
for the user. Those drafts are removed before populating them.

Fixes: #7602.
2018-03-14 10:57:11 -07:00
Shubham Dhama 3b92f6115a hotkey: Add 'delete' to delete focused draft. 2018-03-09 13:30:09 -08:00
Shubham Dhama da65e1dcb6 drafts: Sort drafts by last modified.
This moves the last modified draft to bottom.
2018-02-19 09:55:50 -08:00
Shubham Dhama 804a5f3306 drafts: Add timestamps showing when last modified.
Fixes: #3790.
2018-02-19 09:55:50 -08:00
Aastha Gupta 560425929e compose: Notify when drafts are saved.
Fixes #7539
2017-12-22 10:51:55 -05:00
Marco Burstein 096088969d compose: Re-open the compose editor after restoring a draft.
Fix #5951.
2017-12-22 08:57:39 -05:00
Tommy Ip 6e22847548 refactor: new message content -> compose textarea. 2017-11-28 12:53:40 -08:00
Cynthia Lin e7de4f5d74 hotkeys: Modify draft toggle behavior. 2017-11-03 15:38:10 -07:00
Harshit Bansal eedcbe2d47 drafts: Automatically delete misbehaving drafts while formatting.
While applying formatting to drafts if any draft contains some syntax
which our markdown processor is unable to process delete the draft so
that drafts overlay can be opened without any error. Also report the
exception to the server so that error can be fixed.
2017-10-11 17:44:03 -07:00
Cynthia Lin c87ecf0f63 hotkeys: Prevent drafts overlay from showing while lightbox is open.
Fixes #6757.
2017-10-03 08:36:54 -07:00
Sampriti Panda b2a1754f8a drafts: Re-narrow on restoring draft.
Fixes #4587
2017-06-25 12:26:42 -04:00
Joshua Pan bbc0103183 drafts.js: Create initialize() function. 2017-06-07 00:01:55 -07:00
Rohitt Vashishtha 2d73e03e37 ui-refactor: Rename modals.js to overlays.js.
Fixed #4702.
2017-05-29 11:24:46 -07:00
Rohitt Vashishtha 442537ebb8 overlays: Rename hashchange.exit_modal() to exit_overlay. 2017-05-28 18:40:54 -07:00
Steve Howell 0a0f567aeb Split out markdown.js from echo.js.
The new module handles markdown rendering.

The code left behind in echo.js does local-echo kind of things
like reifying message ids.
2017-05-09 11:06:10 -07:00
Steve Howell 6d1a6934b8 Use modal.open_overlay() in drafts.js. 2017-05-08 22:04:56 -07:00
Mahim Goyal 6464514ca9 Break compose.js and drafts.js dependency. 2017-05-08 14:43:49 -07:00
wangjames 744f4aa663 Fix modals dependency cycle.
This commit forces the files that create modals to create their own
modal closing function instead of creating all of them in the modals
file. These functions are then passed to the modals.close object. This
is intended to remove modals.js's dependencies on these other files.
2017-04-24 14:30:02 -07:00
Steve Howell c999bdf823 compose: Distinguish get_message_type() from composing().
We now only call compose_state.composing() in a boolean context,
where we simply care whether or not the compose box is open.  The
function now also returns true/false.

Callers who need to know the actual message type (e.g. "stream" or
"private") now call compose_state.get_message_type().
2017-04-24 12:42:06 -07:00