From 99b2b8633db4fa3fa21d43f3e6a27694b00908e4 Mon Sep 17 00:00:00 2001
From: Jason <jason.daurus@gmail.com>
Date: Thu, 16 Jun 2016 12:20:32 +0800
Subject: [web] settings store

---
 web/src/js/components/ProxyApp.jsx | 33 +++------------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

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

diff --git a/web/src/js/components/ProxyApp.jsx b/web/src/js/components/ProxyApp.jsx
index 81272268..d7f640a3 100644
--- a/web/src/js/components/ProxyApp.jsx
+++ b/web/src/js/components/ProxyApp.jsx
@@ -7,7 +7,6 @@ import { Splitter } from "./common.js"
 import Header from "./Header"
 import EventLog from "./EventLog"
 import Footer from "./Footer"
-import { SettingsStore } from "../store/store.js"
 import { Key } from "../utils.js"
 
 class ProxyAppMain extends Component {
@@ -24,17 +23,9 @@ class ProxyAppMain extends Component {
     constructor(props, context) {
         super(props, context)
 
-        this.settingsStore = new SettingsStore()
-
-        // Default Settings before fetch
-        _.extend(this.settingsStore.dict, {})
-
-        this.state = { settings: this.settingsStore.dict }
-
         this.focus = this.focus.bind(this)
         this.onKeyDown = this.onKeyDown.bind(this)
         this.updateLocation = this.updateLocation.bind(this)
-        this.onSettingsChange = this.onSettingsChange.bind(this)
     }
 
     /**
@@ -61,29 +52,11 @@ class ProxyAppMain extends Component {
     }
 
     /**
-     * @todo remove settings store
      * @todo connect websocket here
      * @todo listen to window's key events
      */
     componentDidMount() {
         this.focus()
-        this.settingsStore.addListener("recalculate", this.onSettingsChange)
-    }
-
-    /**
-     * @todo remove settings store
-     * @todo disconnect websocket here
-     * @todo stop listening to window's key events
-     */
-    componentWillUnmount() {
-        this.settingsStore.removeListener("recalculate", this.onSettingsChange)
-    }
-
-    /**
-     * @todo move to actions
-     */
-    onSettingsChange() {
-        this.setState({ settings: this.settingsStore.dict })
     }
 
     /**
@@ -143,8 +116,7 @@ class ProxyAppMain extends Component {
     }
 
     render() {
-        const { showEventLog, location, children } = this.props
-        const { settings } = this.state
+        const { showEventLog, location, children, settings } = this.props
         const query = this.getQuery()
         return (
             <div id="container" tabIndex="0" onKeyDown={this.onKeyDown}>
@@ -165,6 +137,7 @@ class ProxyAppMain extends Component {
 
 export default connect(
     state => ({
-        showEventLog: state.eventLog.visible
+        showEventLog: state.eventLog.visible,
+        settings: state.settings.settings,
     })
 )(ProxyAppMain)
-- 
cgit v1.2.3

