aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCadey Dodrill <me@christine.website>2016-12-14 08:24:52 -0800
committerCadey Dodrill <me@christine.website>2016-12-14 08:24:52 -0800
commit449f76cb30be714ef2cec79fa0c53c03773b248d (patch)
treebb2a0c590f3a15ddfd68fd5a3e9b3b3872c3cde3
parent90f176019a1723aa0d4b7cbb97009944e60e963d (diff)
downloadxesite-449f76cb30be714ef2cec79fa0c53c03773b248d.tar.xz
xesite-449f76cb30be714ef2cec79fa0c53c03773b248d.zip
Autoload blogposts on the blog page
-rw-r--r--frontend/src/BlogIndex.purs1
-rw-r--r--frontend/src/Layout.purs7
-rw-r--r--frontend/support/index.html25
3 files changed, 6 insertions, 27 deletions
diff --git a/frontend/src/BlogIndex.purs b/frontend/src/BlogIndex.purs
index 8f2c919..d1b19f6 100644
--- a/frontend/src/BlogIndex.purs
+++ b/frontend/src/BlogIndex.purs
@@ -80,5 +80,4 @@ view state =
div
[]
[ h1 [] [ text state.status ]
- , button [ onClick (const RequestPosts), id_ "requestbutton", className "hidden" ] [ text "Fetch posts" ]
, div [ className "row" ] $ map post state.posts ]
diff --git a/frontend/src/Layout.purs b/frontend/src/Layout.purs
index 93ffa4a..f040108 100644
--- a/frontend/src/Layout.purs
+++ b/frontend/src/Layout.purs
@@ -28,12 +28,17 @@ init =
, bistate: BlogIndex.init }
update :: Action -> State -> EffModel State Action (ajax :: AJAX, dom :: DOM)
-update (PageView route) state = noEffects $ state { route = route }
+update (PageView route) state = routeEffects route $ state { route = route }
update (BIChild action) state = BlogIndex.update action state.bistate
# mapState (state { bistate = _ })
# mapEffects BIChild
update (Child action) state = noEffects $ state { count = Counter.update action state.count }
+routeEffects :: Route -> State -> EffModel State Action (dom :: DOM, ajax :: AJAX)
+routeEffects BlogIndex state = { state: state
+ , effects: [ pure BlogIndex.RequestPosts ] } # mapEffects BIChild
+routeEffects _ state = noEffects $ state
+
view :: State -> Html Action
view state =
div
diff --git a/frontend/support/index.html b/frontend/support/index.html
index 3b53f83..86b06a4 100644
--- a/frontend/support/index.html
+++ b/frontend/support/index.html
@@ -14,30 +14,5 @@
</head>
<body>
<div id="app"></div>
-
- <script>
- // Forgive me
- function eventFire(el, etype){
- if (el.fireEvent) {
- el.fireEvent('on' + etype);
- } else {
- var evObj = document.createEvent('Events');
- evObj.initEvent(etype, true, false);
- el.dispatchEvent(evObj);
- }
- }
-
- interval = setInterval(function() {
- e = document.getElementById("requestbutton");
- if(e != null) {
- eventFire(e, "click");
- } else {
- console.log("Tried so hard been so far")
- }
- clearInterval(interval);
-
- e.style.display = "none";
- }, 250);
- </script>
</body>
</html>