Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
use elm-lang/navigation insted of a port
Browse files Browse the repository at this point in the history
  • Loading branch information
monty5811 committed Jan 25, 2017
1 parent c99190d commit 73dd945
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
12 changes: 6 additions & 6 deletions apostello/static/js/app.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion assets/elm-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"elm-community/list-extra": "4.0.0 <= v < 5.0.0",
"elm-lang/core": "5.0.0 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/http": "1.0.0 <= v < 2.0.0"
"elm-lang/http": "1.0.0 <= v < 2.0.0",
"elm-lang/navigation": "2.1.0 <= v < 3.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}
8 changes: 3 additions & 5 deletions assets/elm/Updates/Fab.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
port module Updates.Fab exposing (update)
module Updates.Fab exposing (update)

import Decoders exposing (decodeAlwaysTrue)
import DjangoSend exposing (post)
Expand All @@ -7,6 +7,7 @@ import Http
import Json.Encode as Encode
import Messages exposing (..)
import Models exposing (..)
import Navigation


update : FabMsg -> Model -> ( Model, Cmd Msg )
Expand All @@ -26,7 +27,7 @@ update msg model =
ReceiveArchiveResp (Ok _) ->
case model.fabModel.archiveButton of
Just ab ->
( model, redirectToUrl ab.redirectUrl )
( model, Navigation.load ab.redirectUrl )

Nothing ->
( model, Cmd.none )
Expand All @@ -53,6 +54,3 @@ archiveItem csrftoken r =
in
post r.postUrl body csrftoken decodeAlwaysTrue
|> Http.send (FabMsg << ReceiveArchiveResp)


port redirectToUrl : String -> Cmd msg
16 changes: 16 additions & 0 deletions assets/elm/elm-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "5.1.1 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"elm-lang/navigation": "2.1.0 <= v < 3.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}
4 changes: 1 addition & 3 deletions assets/js/utils/render_fab.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function renderElm() {

if (node !== null) {
const Elm = require('../../elm/Main.elm');
const app = Elm.Main.embed(node,
Elm.Main.embed(node,
{ pageId: 'fab',
dataUrl: '',
csrftoken: Cookies.get('csrftoken'),
Expand All @@ -33,8 +33,6 @@ function renderElm() {
},
},
);
// setup ports
app.ports.redirectToUrl.subscribe(url => redirect(url));
}
}

Expand Down

0 comments on commit 73dd945

Please sign in to comment.