From 64e8c03dea044752bf3f2f228462721fe565f950 Mon Sep 17 00:00:00 2001
From: Jules Laplace <julescarbon@gmail.com>
Date: Wed, 19 Jul 2017 00:50:05 +0200
Subject: refactor all the worker stuff

---
 client/index.jsx | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

(limited to 'client/index.jsx')

diff --git a/client/index.jsx b/client/index.jsx
index b0815f4..1a8577e 100644
--- a/client/index.jsx
+++ b/client/index.jsx
@@ -2,8 +2,30 @@ import { h, render } from 'preact'
 import { Provider } from 'react-redux'
 import App from './components/App.jsx'
 import store from './store'
+import client from './client'
 import socket from './socket'
 
+import { loadFolders, loadOpenFolders, loadFiles, loadTasks } from './actions/index.js'
+
+client.folder.index().then( folders => {
+  store.dispatch(loadFolders(folders))
+  try {
+    const openFolders = JSON.parse(localStorage['openFolders'])
+    store.dispatch( loadOpenFolders(openFolders) )
+    openFolders.forEach( folder_id => {
+      client.file.index({ folder_id }).then( files => {
+        store.dispatch(loadFiles(files))
+      })
+    })
+  }
+  catch (e) {
+    console.log('error opening folders')
+  }
+})
+client.task.index().then( tasks => {
+  store.dispatch(loadTasks(tasks))
+})
+
 const app = (
   <Provider store={store}>
     <App />
-- 
cgit v1.2.3-70-g09d2

