From 05a3720dfd23a6845beb65aeb9e59c0eb50b8e63 Mon Sep 17 00:00:00 2001
From: john <johnbarlas39@gmail.com>
Date: Fri, 16 Dec 2016 01:10:58 +0200
Subject: [PATCH] attempt at saving upload state in localstorage

---
 app/components/BookBuilder/Chapter.jsx  | 35 +++++++++++++++++++++++++
 app/components/BookBuilder/Division.jsx |  2 +-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/app/components/BookBuilder/Chapter.jsx b/app/components/BookBuilder/Chapter.jsx
index 5f95314..636c9d5 100644
--- a/app/components/BookBuilder/Chapter.jsx
+++ b/app/components/BookBuilder/Chapter.jsx
@@ -28,8 +28,41 @@ export class Chapter extends React.Component {
     this.setState({
       isUploadInProgress: !this.state.isUploadInProgress
     })
+
+    // if (!this.state.isUploadInProgress) this.removeUploadState()
   }
 
+  // getLocalStorageKey () {
+  //   const { chapter } = this.props
+  //   return 'chapter:upload:' + chapter.id
+  // }
+  //
+  // persistUploadState () {
+  //   const key = this.getLocalStorageKey()
+  //   window.localStorage.setItem(key, true)
+  // }
+  //
+  // removeUploadState () {
+  //   const key = this.getLocalStorageKey()
+  //   window.localStorage.removeItem(key)
+  // }
+  //
+  // componentWillMount () {
+  //   const key = this.getLocalStorageKey()
+  //   var entry = window.localStorage.getItem(key)
+  //   if (entry) {
+  //     this.setState({
+  //       isUploadInProgress: true
+  //     })
+  //   }
+  // }
+  //
+  // componentWillUnmount () {
+  //   if (this.state.isUploadInProgress) {
+  //     this.persistUploadState()
+  //   }
+  // }
+
   render () {
     const {
       book,
@@ -51,6 +84,8 @@ export class Chapter extends React.Component {
       opacity: isDragging ? 0 : 1
     }
 
+    // TODO -- refactor these huge class names
+    // TODO -- make the dot and line component/s
     return connectDragSource(connectDropTarget(
       <li
         className={styles.chapterContainer + ' col-lg-12 bb-chapter ' + (chapter.subCategory === 'chapter' ? styles.isChapter : styles.isPart)}
diff --git a/app/components/BookBuilder/Division.jsx b/app/components/BookBuilder/Division.jsx
index efd4b54..97238b8 100644
--- a/app/components/BookBuilder/Division.jsx
+++ b/app/components/BookBuilder/Division.jsx
@@ -114,9 +114,9 @@ export class Division extends React.Component {
         <Chapter
           book={book}
           chapter={c}
-          key={c.index}
           id={c.id}
           ink={ink}
+          key={c.index}
           move={_onMove}
           no={i}
           outerContainer={outerContainer}
-- 
GitLab