mirror of https://github.com/zulip/zulip.git
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.
This commit is contained in:
parent
4ac2db56f8
commit
c4cd0fe0c1
|
@ -257,27 +257,13 @@ run_test('format_drafts', () => {
|
|||
|
||||
var expected = [
|
||||
{
|
||||
draft_id: 'id3',
|
||||
draft_id: 'id1',
|
||||
is_stream: true,
|
||||
stream: 'stream 2',
|
||||
stream: 'stream',
|
||||
stream_color: '#FFFFFF',
|
||||
topic: 'topic',
|
||||
raw_content: 'Test Stream Message 2',
|
||||
time_stamp: 'Jan 21',
|
||||
},
|
||||
{
|
||||
draft_id: 'id4',
|
||||
is_stream: false,
|
||||
recipients: 'aaron',
|
||||
raw_content: 'Test Private Message 2',
|
||||
time_stamp: 'Jan 26',
|
||||
},
|
||||
{
|
||||
draft_id: 'id5',
|
||||
is_stream: false,
|
||||
recipients: 'aaron',
|
||||
raw_content: 'Test Private Message 3',
|
||||
time_stamp: 'Jan 29',
|
||||
raw_content: 'Test Stream Message',
|
||||
time_stamp: '7:55 AM',
|
||||
},
|
||||
{
|
||||
draft_id: 'id2',
|
||||
|
@ -287,13 +273,27 @@ run_test('format_drafts', () => {
|
|||
time_stamp: 'Jan 30',
|
||||
},
|
||||
{
|
||||
draft_id: 'id1',
|
||||
draft_id: 'id5',
|
||||
is_stream: false,
|
||||
recipients: 'aaron',
|
||||
raw_content: 'Test Private Message 3',
|
||||
time_stamp: 'Jan 29',
|
||||
},
|
||||
{
|
||||
draft_id: 'id4',
|
||||
is_stream: false,
|
||||
recipients: 'aaron',
|
||||
raw_content: 'Test Private Message 2',
|
||||
time_stamp: 'Jan 26',
|
||||
},
|
||||
{
|
||||
draft_id: 'id3',
|
||||
is_stream: true,
|
||||
stream: 'stream',
|
||||
stream: 'stream 2',
|
||||
stream_color: '#FFFFFF',
|
||||
topic: 'topic',
|
||||
raw_content: 'Test Stream Message',
|
||||
time_stamp: '7:55 AM',
|
||||
raw_content: 'Test Stream Message 2',
|
||||
time_stamp: 'Jan 21',
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ exports.launch = function () {
|
|||
var unsorted_raw_drafts = _.values(data);
|
||||
|
||||
var sorted_raw_drafts = unsorted_raw_drafts.sort(function (draft_a, draft_b) {
|
||||
return draft_a.updatedAt - draft_b.updatedAt;
|
||||
return draft_b.updatedAt - draft_a.updatedAt;
|
||||
});
|
||||
|
||||
var sorted_formatted_drafts = _.filter(_.map(sorted_raw_drafts, exports.format_draft));
|
||||
|
@ -463,12 +463,12 @@ exports.open_modal = function () {
|
|||
|
||||
exports.set_initial_element = function (drafts) {
|
||||
if (drafts.length > 0) {
|
||||
var curr_draft_id = drafts[drafts.length - 1].draft_id;
|
||||
var curr_draft_id = drafts[0].draft_id;
|
||||
var selector = '[data-draft-id="' + curr_draft_id + '"]';
|
||||
var curr_draft_element = document.querySelectorAll(selector);
|
||||
var focus_element = curr_draft_element[0].children[0];
|
||||
activate_element(focus_element);
|
||||
$(".drafts-list")[0].scrollTop = $('.drafts-list')[0].scrollHeight - $('.drafts-list').height();
|
||||
$(".drafts-list")[0].scrollTop = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue