Skip to content

Commit

Permalink
Displaying conversation in a descending chronological order (Foundry3…
Browse files Browse the repository at this point in the history
…76#25)

* Implementing a descending order view of the message list

* Moved the option under the reading section in preferences and changed the wording of the option

* Forgot to update .gitignore
  • Loading branch information
tsikerdekis authored and mikeseese committed Sep 15, 2017
1 parent 00f658a commit 1511bee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
21 changes: 16 additions & 5 deletions app/internal_packages/message-list/lib/message-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,22 @@ class MessageList extends React.Component {

_messageElements() {
const {messagesExpandedState, currentThread} = this.state;
const elements = []
const elements = [];
let lastMessageIdx;

const lastItem = this.state.messages[this.state.messages.length - 1];
const descendingOrderMessageList = NylasEnv.config.get('core.reading.descendingOrderMessageList');
let messages = this._messagesWithMinification(this.state.messages);

// Check on whether to display items in descending order
if (descendingOrderMessageList) {
messages = messages.reverse();
lastMessageIdx = 0;
} else {
lastMessageIdx = messages.length - 1;
}

const lastItem = this.state.messages[descendingOrderMessageList ? 0 : this.state.messages.length - 1];
const hasReplyArea = lastItem && !lastItem.draft;
const messages = this._messagesWithMinification(this.state.messages)

messages.forEach((message, idx) => {
if (message.type === "minifiedBundle") {
Expand All @@ -251,7 +262,7 @@ class MessageList extends React.Component {
}

const collapsed = !messagesExpandedState[message.id];
const isLastItem = (messages.length - 1 === idx);
const isLastItem = (lastMessageIdx === idx);
const isBeforeReplyArea = isLastItem && hasReplyArea;

elements.push(
Expand All @@ -268,7 +279,7 @@ class MessageList extends React.Component {
/>
);
});
if (hasReplyArea) {
if (hasReplyArea && lastItem) {
elements.push(this._renderReplyArea());
}
return elements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ body.platform-win32 {
overflow: hidden;

max-width: @message-max-width;
margin: -3px auto 0 auto;
margin: -3px auto 10px auto;

position: relative;
z-index: 2;
Expand Down
5 changes: 5 additions & 0 deletions app/src/config-schema.es6
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export default {
'default': false,
'title': "Swipe gesture and backspace / delete move messages to trash",
},
descendingOrderMessageList: {
'type': 'boolean',
'default': false,
'title': "Display conversations in descending chronological order",
},
},
},
composing: {
Expand Down

0 comments on commit 1511bee

Please sign in to comment.