From 17337e6b84317b9dd55c79a3177dfd981d1cfba9 Mon Sep 17 00:00:00 2001 From: wes Date: Mon, 19 Jun 2017 19:36:49 -0400 Subject: [PATCH] fix duplicates --- src/scripts/editor.tag | 6 +++--- src/scripts/zipper.js | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/scripts/editor.tag b/src/scripts/editor.tag index 34301a7..68fa9dd 100644 --- a/src/scripts/editor.tag +++ b/src/scripts/editor.tag @@ -166,7 +166,7 @@ submit() { /* Refresh the current list of posts */ self._id = resp.data[0]; self.listPosts(); - console.log(self.currentPosts); + console.log(Z.toJS(self.currentPosts)); }) .catch(function(err) { console.log(err); @@ -197,9 +197,9 @@ deletePost(_id) { return function() { axios.get(`/blog/deletepost/${self.currentPost()._id}`) .then(function(resp) { - self.update({"currentPosts" : Z.empty}); self.newPost(); self.listPosts(); + console.log(Z.toJS(self.currentPosts)); }) .catch(function(err) { console.log(err); @@ -212,7 +212,7 @@ listPosts() { .then(function(resp) { self.update( { - "currentPosts" : Z.extend(self.currentPosts, resp.data) + "currentPosts" : Z.extend(Z.empty, resp.data) } ); }) diff --git a/src/scripts/zipper.js b/src/scripts/zipper.js index ee9392c..09e476b 100644 --- a/src/scripts/zipper.js +++ b/src/scripts/zipper.js @@ -7,6 +7,10 @@ function Zipper(left, right) { }; } +function toJS(z) { + return [z.left.toJS(), z.right.toJS()]; +} + function fromList(xs) { return Zipper(im.Stack(), im.Stack(xs)); } @@ -61,5 +65,6 @@ export default { "empty" : empty, "fromList" : fromList, "extend" : extend, - "removeCurrent" : removeCurrent + "removeCurrent" : removeCurrent, + "toJS" : toJS };