From b3ccfc4f19608c55bf851edc8143663d418f3be2 Mon Sep 17 00:00:00 2001 From: liamcardenas Date: Thu, 15 Mar 2018 11:26:09 -0700 Subject: [PATCH 1/4] Add height sorting back in where appropriate --- src/renderer/component/fileList/view.jsx | 30 ++++++++++++++++++-- src/renderer/page/fileListPublished/view.jsx | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/renderer/component/fileList/view.jsx b/src/renderer/component/fileList/view.jsx index 7afe8998d..c52dd3fda 100644 --- a/src/renderer/component/fileList/view.jsx +++ b/src/renderer/component/fileList/view.jsx @@ -13,8 +13,34 @@ class FileList extends React.PureComponent { }; this._sortFunctions = { - dateNew: fileInfos => [...fileInfos].reverse(), - dateOld: fileInfos => fileInfos, + dateNew: fileInfos => this.props.sortByHeight ? fileInfos.slice().sort((fileInfo1, fileInfo2) => { + const height1 = this.props.claimsById[fileInfo1.claim_id] + ? this.props.claimsById[fileInfo1.claim_id].height + : 0; + const height2 = this.props.claimsById[fileInfo2.claim_id] + ? this.props.claimsById[fileInfo2.claim_id].height + : 0; + if (height1 > height2) { + return -1; + } else if (height1 < height2) { + return 1; + } + return 0; + }) : [...fileInfos].reverse(), + dateOld: fileInfos => this.props.sortByHeight ? fileInfos.slice().sort((fileInfo1, fileInfo2) => { + const height1 = this.props.claimsById[fileInfo1.claim_id] + ? this.props.claimsById[fileInfo1.claim_id].height + : 999999; + const height2 = this.props.claimsById[fileInfo2.claim_id] + ? this.props.claimsById[fileInfo2.claim_id].height + : 999999; + if (height1 < height2) { + return -1; + } else if (height1 > height2) { + return 1; + } + return 0; + }) : fileInfos, title: fileInfos => fileInfos.slice().sort((fileInfo1, fileInfo2) => { const title1 = fileInfo1.value diff --git a/src/renderer/page/fileListPublished/view.jsx b/src/renderer/page/fileListPublished/view.jsx index de19dd1dd..e7917f67d 100644 --- a/src/renderer/page/fileListPublished/view.jsx +++ b/src/renderer/page/fileListPublished/view.jsx @@ -25,6 +25,7 @@ class FileListPublished extends React.PureComponent { fileInfos={claims} fetching={isFetching} fileTileShowEmpty={FileTile.SHOW_EMPTY_PENDING} + sortByHeight /> ); } else if (isFetching) { -- 2.45.3 From a6ab95105a73885a3ba1a06ed65ff7998bc8b4e1 Mon Sep 17 00:00:00 2001 From: liamcardenas Date: Thu, 15 Mar 2018 11:27:47 -0700 Subject: [PATCH 2/4] Formatted changes via prettier --- src/renderer/component/fileList/view.jsx | 62 +++++++++++++----------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/src/renderer/component/fileList/view.jsx b/src/renderer/component/fileList/view.jsx index c52dd3fda..9c926e825 100644 --- a/src/renderer/component/fileList/view.jsx +++ b/src/renderer/component/fileList/view.jsx @@ -13,34 +13,40 @@ class FileList extends React.PureComponent { }; this._sortFunctions = { - dateNew: fileInfos => this.props.sortByHeight ? fileInfos.slice().sort((fileInfo1, fileInfo2) => { - const height1 = this.props.claimsById[fileInfo1.claim_id] - ? this.props.claimsById[fileInfo1.claim_id].height - : 0; - const height2 = this.props.claimsById[fileInfo2.claim_id] - ? this.props.claimsById[fileInfo2.claim_id].height - : 0; - if (height1 > height2) { - return -1; - } else if (height1 < height2) { - return 1; - } - return 0; - }) : [...fileInfos].reverse(), - dateOld: fileInfos => this.props.sortByHeight ? fileInfos.slice().sort((fileInfo1, fileInfo2) => { - const height1 = this.props.claimsById[fileInfo1.claim_id] - ? this.props.claimsById[fileInfo1.claim_id].height - : 999999; - const height2 = this.props.claimsById[fileInfo2.claim_id] - ? this.props.claimsById[fileInfo2.claim_id].height - : 999999; - if (height1 < height2) { - return -1; - } else if (height1 > height2) { - return 1; - } - return 0; - }) : fileInfos, + dateNew: fileInfos => + this.props.sortByHeight + ? fileInfos.slice().sort((fileInfo1, fileInfo2) => { + const height1 = this.props.claimsById[fileInfo1.claim_id] + ? this.props.claimsById[fileInfo1.claim_id].height + : 0; + const height2 = this.props.claimsById[fileInfo2.claim_id] + ? this.props.claimsById[fileInfo2.claim_id].height + : 0; + if (height1 > height2) { + return -1; + } else if (height1 < height2) { + return 1; + } + return 0; + }) + : [...fileInfos].reverse(), + dateOld: fileInfos => + this.props.sortByHeight + ? fileInfos.slice().sort((fileInfo1, fileInfo2) => { + const height1 = this.props.claimsById[fileInfo1.claim_id] + ? this.props.claimsById[fileInfo1.claim_id].height + : 999999; + const height2 = this.props.claimsById[fileInfo2.claim_id] + ? this.props.claimsById[fileInfo2.claim_id].height + : 999999; + if (height1 < height2) { + return -1; + } else if (height1 > height2) { + return 1; + } + return 0; + }) + : fileInfos, title: fileInfos => fileInfos.slice().sort((fileInfo1, fileInfo2) => { const title1 = fileInfo1.value -- 2.45.3 From 0230757bb644faf5d902726701cdd1a0cb6f2bd6 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Thu, 15 Mar 2018 16:39:52 -0400 Subject: [PATCH 3/4] Add option to kill running daemon when incompatible --- .../modal/modalIncompatibleDaemon/index.js | 8 +++----- .../modal/modalIncompatibleDaemon/view.jsx | 18 ++++++++++++++---- src/renderer/redux/actions/app.js | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/src/renderer/modal/modalIncompatibleDaemon/index.js b/src/renderer/modal/modalIncompatibleDaemon/index.js index fda1b57f9..6bd45aa43 100644 --- a/src/renderer/modal/modalIncompatibleDaemon/index.js +++ b/src/renderer/modal/modalIncompatibleDaemon/index.js @@ -1,12 +1,10 @@ -import React from 'react'; import { connect } from 'react-redux'; -import { doQuit, doSkipWrongDaemonNotice } from 'redux/actions/app'; +import { doQuit, doQuitAnyDaemon } from 'redux/actions/app'; import ModalIncompatibleDaemon from './view'; -const select = state => ({}); - const perform = dispatch => ({ quit: () => dispatch(doQuit()), + quitAnyDaemon: () => dispatch(doQuitAnyDaemon()), }); -export default connect(select, perform)(ModalIncompatibleDaemon); +export default connect(perform)(ModalIncompatibleDaemon); diff --git a/src/renderer/modal/modalIncompatibleDaemon/view.jsx b/src/renderer/modal/modalIncompatibleDaemon/view.jsx index cfab04ab1..ab7941795 100644 --- a/src/renderer/modal/modalIncompatibleDaemon/view.jsx +++ b/src/renderer/modal/modalIncompatibleDaemon/view.jsx @@ -1,18 +1,28 @@ +// @flow + import React from 'react'; import { Modal } from 'modal/modal'; import Link from 'component/link/index'; +import type { Dispatch } from 'src/renderer/redux/actions/shape_shift'; -class ModalIncompatibleDaemon extends React.PureComponent { +type Props = { + quit: Dispatch, + quitAnyDaemon: Dispatch, +}; + +class ModalIncompatibleDaemon extends React.PureComponent { render() { - const { quit } = this.props; + const { quit, quitAnyDaemon } = this.props; return ( {__( 'This browser is running with an incompatible version of the LBRY protocol and your install must be repaired. ' diff --git a/src/renderer/redux/actions/app.js b/src/renderer/redux/actions/app.js index 6a1f138ba..1421d62e0 100644 --- a/src/renderer/redux/actions/app.js +++ b/src/renderer/redux/actions/app.js @@ -1,3 +1,4 @@ +import { execSync } from 'child_process'; import isDev from 'electron-is-dev'; import Lbry from 'lbry'; import path from 'path'; @@ -323,6 +324,20 @@ export function doClearCache() { }; } +export function doQuitAnyDaemon() { + return dispatch => { + try { + if (process.platform === 'win32') { + execSync('taskkill /im lbrynet-daemon.exe /t /f'); + } else { + execSync('pkill lbrynet-daemon'); + } + } catch (error) { + dispatch(doAlertError(`Quitting daemon failed due to: ${error.message}`)); + } + }; +} + export function doQuit() { return () => { remote.app.quit(); -- 2.45.3 From dc367fd51297f04c18ec3bbb3f49381e559e08c1 Mon Sep 17 00:00:00 2001 From: Igor Gassmann Date: Thu, 15 Mar 2018 17:34:00 -0400 Subject: [PATCH 4/4] Fix option to kill running daemon when incompatible --- .../modal/modalIncompatibleDaemon/index.js | 2 +- .../modal/modalIncompatibleDaemon/view.jsx | 12 ++---------- src/renderer/redux/actions/app.js | 14 ++++++++------ 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/renderer/modal/modalIncompatibleDaemon/index.js b/src/renderer/modal/modalIncompatibleDaemon/index.js index 6bd45aa43..8feed2ca7 100644 --- a/src/renderer/modal/modalIncompatibleDaemon/index.js +++ b/src/renderer/modal/modalIncompatibleDaemon/index.js @@ -7,4 +7,4 @@ const perform = dispatch => ({ quitAnyDaemon: () => dispatch(doQuitAnyDaemon()), }); -export default connect(perform)(ModalIncompatibleDaemon); +export default connect(null, perform)(ModalIncompatibleDaemon); diff --git a/src/renderer/modal/modalIncompatibleDaemon/view.jsx b/src/renderer/modal/modalIncompatibleDaemon/view.jsx index ab7941795..3526ab4e9 100644 --- a/src/renderer/modal/modalIncompatibleDaemon/view.jsx +++ b/src/renderer/modal/modalIncompatibleDaemon/view.jsx @@ -1,16 +1,8 @@ -// @flow - import React from 'react'; import { Modal } from 'modal/modal'; import Link from 'component/link/index'; -import type { Dispatch } from 'src/renderer/redux/actions/shape_shift'; -type Props = { - quit: Dispatch, - quitAnyDaemon: Dispatch, -}; - -class ModalIncompatibleDaemon extends React.PureComponent { +class ModalIncompatibleDaemon extends React.PureComponent { render() { const { quit, quitAnyDaemon } = this.props; @@ -18,7 +10,7 @@ class ModalIncompatibleDaemon extends React.PureComponent { { + remote.app.quit(); + }; +} + export function doQuitAnyDaemon() { return dispatch => { try { @@ -334,16 +340,12 @@ export function doQuitAnyDaemon() { } } catch (error) { dispatch(doAlertError(`Quitting daemon failed due to: ${error.message}`)); + } finally { + dispatch(doQuit()); } }; } -export function doQuit() { - return () => { - remote.app.quit(); - }; -} - export function doChangeVolume(volume) { return dispatch => { dispatch({ -- 2.45.3