Skip to content

Commit 7d95c13

Browse files
committed
Sort converation parts by insertedAt:asc
1 parent 98ddd4b commit 7d95c13

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

app/templates/components/conversations/conversation-thread.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
sentAt=conversation.message.insertedAt
99
}}
1010
{{/if}}
11-
{{#each conversation.conversationParts as |conversationPart|}}
11+
{{#each (sort-by "insertedAt:asc" conversation.conversationParts) as |conversationPart|}}
1212
{{#if conversationPart.isLoaded}}
1313
{{conversations/conversation-part
1414
author=conversationPart.author

tests/integration/components/conversations/conversation-thread-test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,21 @@ test('it delays rendering head until loaded', function(assert) {
6060
assert.equal(page.conversationParts().count, 0, 'No part is rendered.');
6161
});
6262

63-
test('it renders each conversation part', function(assert) {
63+
test('it renders each conversation part, sorted by insertedAt', function(assert) {
6464
assert.expect(4);
6565

6666
let conversationParts = [
67-
{ isLoaded: true, body: 'foo 1' },
68-
{ isLoaded: true, body: 'foo 2' },
69-
{ isLoaded: true, body: 'foo 3' }
67+
{ isLoaded: true, body: 'foo 1', insertedAt: new Date("2017-11-01") },
68+
{ isLoaded: true, body: 'foo 2', insertedAt: new Date("2017-12-01") },
69+
{ isLoaded: true, body: 'foo 3', insertedAt: new Date("2017-10-01") }
7070
];
7171
set(this, 'conversation', { conversationParts });
7272
renderPage();
7373

7474
assert.equal(page.conversationParts().count, 3, 'Each part is rendered.');
75-
assert.equal(page.conversationParts(0).body.text, 'foo 1', 'Part 1 is rendered correctly.');
76-
assert.equal(page.conversationParts(1).body.text, 'foo 2', 'Part 2 is rendered correctly.');
77-
assert.equal(page.conversationParts(2).body.text, 'foo 3', 'Part 3 is rendered correctly.');
75+
assert.equal(page.conversationParts(1).body.text, 'foo 1', 'Part 1 is rendered second to last.');
76+
assert.equal(page.conversationParts(2).body.text, 'foo 2', 'Part 2 is rendered last (newest).');
77+
assert.equal(page.conversationParts(0).body.text, 'foo 3', 'Part 3 is rendered first (earliest date).');
7878
});
7979

8080
test('it delays rendering conversation parts not yet loaded', function(assert) {

0 commit comments

Comments
 (0)