From 8b43972b95f002e8a5d8a85b7a53f43f16711362 Mon Sep 17 00:00:00 2001
From: Clemens <cle1000.cb@gmail.com>
Date: Wed, 10 Aug 2016 10:49:27 +0200
Subject: move content to redux, add lines to view

---
 web/src/js/components/ContentView/ContentViews.jsx | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

(limited to 'web/src/js/components/ContentView/ContentViews.jsx')

diff --git a/web/src/js/components/ContentView/ContentViews.jsx b/web/src/js/components/ContentView/ContentViews.jsx
index 9feb0623..cd593023 100644
--- a/web/src/js/components/ContentView/ContentViews.jsx
+++ b/web/src/js/components/ContentView/ContentViews.jsx
@@ -1,6 +1,6 @@
 import React, { PropTypes, Component } from 'react'
 import { connect } from 'react-redux'
-import { setContentViewDescription, setShowFullContent } from '../../ducks/ui/flow'
+import { setContentViewDescription, setContent } from '../../ducks/ui/flow'
 import ContentLoader from './ContentLoader'
 import { MessageUtils } from '../../flow/utils'
 import CodeEditor from './CodeEditor'
@@ -30,28 +30,25 @@ function Edit({ content, onChange }) {
 Edit = ContentLoader(Edit)
 
 class ViewServer extends Component {
-    static defaultProps = {
-        maxLines: 80,
-    }
 
     componentWillMount(){
         this.setContentView(this.props)
     }
 
     componentWillReceiveProps(nextProps){
-        this.setContentView(nextProps)
+        if (nextProps.content != this.props.content) {
+            this.setContentView(nextProps)
+        }
     }
     setContentView(props){
         try {
             this.data = JSON.parse(props.content)
         }catch(err) {
-            this.data= {lines: [], description: err.message}
+            this.data = {lines: [], description: err.message}
         }
 
         props.setContentViewDescription(props.contentView != this.data.description ? this.data.description : '')
-
-        let isFullContentShown = this.data.lines.length < props.maxLines
-        if (isFullContentShown) props.setShowFullContent(true)
+        props.setContent(this.data.lines)
     }
     render() {
         const {content, contentView, message, maxLines} = this.props
@@ -78,11 +75,12 @@ class ViewServer extends Component {
 
 ViewServer = connect(
     state => ({
-        showFullContent: state.ui.flow.showFullContent
+        showFullContent: state.ui.flow.showFullContent,
+        maxLines: state.ui.flow.maxContentLines
     }),
     {
         setContentViewDescription,
-        setShowFullContent
+        setContent
     }
 )(ContentLoader(ViewServer))
 
-- 
cgit v1.2.3

