From 96e4163c6156a7ecb34ab1eb9dbebf0921c8f6ae Mon Sep 17 00:00:00 2001 From: Jeremy Curcio Date: Thu, 15 Feb 2018 10:21:35 -0500 Subject: [PATCH] Fix sort by date --- src/renderer/component/fileList/view.jsx | 34 +++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/renderer/component/fileList/view.jsx b/src/renderer/component/fileList/view.jsx index 8dcccadc3..cca8dec98 100644 --- a/src/renderer/component/fileList/view.jsx +++ b/src/renderer/component/fileList/view.jsx @@ -9,12 +9,35 @@ class FileList extends React.PureComponent { super(props); this.state = { - sortBy: 'date', + sortBy: 'dateNew', }; this._sortFunctions = { - date(fileInfos) { - return fileInfos.slice().reverse(); + dateNew(fileInfos) { + return fileInfos.slice().sort((fileInfo1, fileInfo2) => { + console.log(fileInfo1); + const height1 = fileInfo1.height + const height2 = fileInfo2.height + if (height1 > height2) { + return -1; + } else if (height1 < height2) { + return 1; + } + return 0; + }); + }, + dateOld(fileInfos) { + return fileInfos.slice().sort((fileInfo1, fileInfo2) => { + console.log(fileInfo1); + const height1 = fileInfo1.height + const height2 = fileInfo2.height + if (height1 < height2) { + return -1; + } else if (height1 > height2) { + return 1; + } + return 0; + }); }, title(fileInfos) { return fileInfos.slice().sort((fileInfo1, fileInfo2) => { @@ -65,6 +88,8 @@ class FileList extends React.PureComponent { const { sortBy } = this.state; const content = []; + console.log(sortBy); + this._sortFunctions[sortBy](fileInfos).forEach(fileInfo => { const uriParams = {}; @@ -95,7 +120,8 @@ class FileList extends React.PureComponent { {__('Sort by')}{' '} - + +