summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-06-22 18:07:06 +0200
committerJules Laplace <julescarbon@gmail.com>2018-06-22 18:07:06 +0200
commit9359758ce631528ae2b0deb82df05f908d5c42a2 (patch)
treeb6a43b59ca22c8bd0acf79e7a4b3f1beb20470eb
parent3347e241b860001721cb8c07fc6a82b51f97335e (diff)
why is this double encoded
-rw-r--r--app/client/dashboard/dashboardHeader.component.js3
-rw-r--r--app/client/socket/socket.task.js18
2 files changed, 17 insertions, 4 deletions
diff --git a/app/client/dashboard/dashboardHeader.component.js b/app/client/dashboard/dashboardHeader.component.js
index 9acee35..10b2241 100644
--- a/app/client/dashboard/dashboardHeader.component.js
+++ b/app/client/dashboard/dashboardHeader.component.js
@@ -44,13 +44,12 @@ class DashboardHeader extends Component {
<div>
Currently {util.gerund(task.activity)} {task.module} on {task.dataset}<br/>
{eta && <span>Epoch: {task.epoch} / {task.epochs}, ETA {eta}<br/></span>}
- <br />
- Want to play live? <button>Pause at the end of this epoch</button>
</div>
)
}
}
}
+// Want to play live? <button>Pause at the end of this epoch</button>
const mapStateToProps = state => ({
runner: state.system.runner,
diff --git a/app/client/socket/socket.task.js b/app/client/socket/socket.task.js
index 77f1310..1b33cd9 100644
--- a/app/client/socket/socket.task.js
+++ b/app/client/socket/socket.task.js
@@ -5,9 +5,23 @@ import { socket } from './socket.connection'
let finishTimeout;
-socket.on('task_res', (data) => {
+socket.on('task_res', (raw_data) => {
// does not like the nested task object for some reason..
- data = JSON.parse(data)
+ console.log(typeof raw_data)
+ let data;
+ try {
+ if (typeof raw_data === 'string') {
+ data = JSON.parse(raw_data)
+ if (typeof data === 'string') {
+ data = JSON.parse(data)
+ }
+ } else {
+ data = raw_data
+ }
+ } catch (e) {
+ console.warn('problem with json', e)
+ return
+ }
if (data.task) {
dispatch({ type: types.task.update, data: data.task })
}