From 157e02a362e59a162029a681fe0b02114c030917 Mon Sep 17 00:00:00 2001
From: Taniaf26 <tania.fecheta@gmail.com>
Date: Thu, 4 Oct 2018 14:35:33 +0300
Subject: [PATCH] perf: replace withVerion to get only the last fragment of a
 collection

hin-1020
---
 .../src/components/Dashboard/DashboardItems.js    |  8 ++++----
 .../src/components/Dashboard/withVersion.js       | 15 ---------------
 .../components-faraday/src/components/index.js    |  1 -
 packages/hindawi-theme/src/elements/Accordion.js  |  2 +-
 4 files changed, 5 insertions(+), 21 deletions(-)
 delete mode 100644 packages/components-faraday/src/components/Dashboard/withVersion.js

diff --git a/packages/components-faraday/src/components/Dashboard/DashboardItems.js b/packages/components-faraday/src/components/Dashboard/DashboardItems.js
index f40111b65..97c067c08 100644
--- a/packages/components-faraday/src/components/Dashboard/DashboardItems.js
+++ b/packages/components-faraday/src/components/Dashboard/DashboardItems.js
@@ -5,17 +5,17 @@ import { connect } from 'react-redux'
 import styled from 'styled-components'
 import { th } from '@pubsweet/ui-toolkit'
 import { withRouter } from 'react-router-dom'
-import { compose, setDisplayName, withHandlers } from 'recompose'
+import { compose, setDisplayName, withHandlers, withProps } from 'recompose'
 import { ManuscriptCard, Row } from 'pubsweet-component-faraday-ui'
 import { canViewReports } from 'pubsweet-component-faraday-selectors'
 
-import withVersion from './withVersion'
-
 const DashboardItem = compose(
-  withVersion,
   connect((state, { collection }) => ({
     canViewReports: canViewReports(state, get(collection, 'id', '')),
   })),
+  withProps(({ collection }) => ({
+    fragment: get(collection, 'currentVersion', {}),
+  })),
 )(ManuscriptCard)
 
 const DashboardItems = ({ list, onClick, deleteProject, canViewReports }) => (
diff --git a/packages/components-faraday/src/components/Dashboard/withVersion.js b/packages/components-faraday/src/components/Dashboard/withVersion.js
deleted file mode 100644
index 247297301..000000000
--- a/packages/components-faraday/src/components/Dashboard/withVersion.js
+++ /dev/null
@@ -1,15 +0,0 @@
-import { compose } from 'recompose'
-import { connect } from 'react-redux'
-import { actions } from 'pubsweet-client'
-import { ConnectPage } from 'xpub-connect'
-import { selectCurrentVersion } from 'xpub-selectors'
-
-export default Component =>
-  compose(
-    ConnectPage(({ collection }) => [
-      actions.getFragments({ id: collection.id }),
-    ]),
-    connect((state, { collection }) => ({
-      fragment: selectCurrentVersion(state, collection) || {},
-    })),
-  )(Component)
diff --git a/packages/components-faraday/src/components/index.js b/packages/components-faraday/src/components/index.js
index eb71acbe3..6d41e12da 100644
--- a/packages/components-faraday/src/components/index.js
+++ b/packages/components-faraday/src/components/index.js
@@ -2,7 +2,6 @@ import { Decision } from './MakeDecision'
 import * as Components from './UIComponents'
 
 export { FormItems } from './UIComponents'
-export { default as withVersion } from './Dashboard/withVersion.js'
 export { default as UserProfilePage } from './UserProfile/UserProfilePage'
 export { default as ChangePasswordPage } from './UserProfile/ChangePasswordPage'
 
diff --git a/packages/hindawi-theme/src/elements/Accordion.js b/packages/hindawi-theme/src/elements/Accordion.js
index f6c4a305a..6eb7224de 100644
--- a/packages/hindawi-theme/src/elements/Accordion.js
+++ b/packages/hindawi-theme/src/elements/Accordion.js
@@ -36,7 +36,7 @@ export default {
           ? th('accordion.headerBackgroundColor')
           : 'transparent'};
       border-radius: ${props => (props.expanded ? 0 : th('borderRadius'))};
-      borde-border-top-left-radius: ${th('borderRadius')};
+      border-top-left-radius: ${th('borderRadius')};
       border-top-right-radius: ${th('borderRadius')};
       border-bottom: ${props =>
         props.expanded && !props.transparent ? th('accordion.border') : 'none'};
-- 
GitLab