summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/roster-editor/src/Comm/Send.elm2
-rw-r--r--src/roster-editor/src/Struct/ServerReply.elm1
-rw-r--r--src/roster-editor/src/Update/HandleServerReply.elm17
-rw-r--r--src/shared/elm/Comm/GoTo.elm27
4 files changed, 47 insertions, 0 deletions
diff --git a/src/roster-editor/src/Comm/Send.elm b/src/roster-editor/src/Comm/Send.elm
index a4cdf3b..c156a23 100644
--- a/src/roster-editor/src/Comm/Send.elm
+++ b/src/roster-editor/src/Comm/Send.elm
@@ -13,6 +13,7 @@ import Comm.AddGlyph
import Comm.AddGlyphBoard
import Comm.AddPortrait
import Comm.AddWeapon
+import Comm.GoTo
import Comm.SetInventory
import Struct.Event
@@ -40,6 +41,7 @@ internal_decoder reply_type =
"add_glyph_board" -> (Comm.AddGlyphBoard.decode)
"disconnected" -> (Json.Decode.succeed Struct.ServerReply.Disconnected)
+ "goto" -> (Comm.GoTo.decode)
"okay" -> (Json.Decode.succeed Struct.ServerReply.Okay)
other ->
diff --git a/src/roster-editor/src/Struct/ServerReply.elm b/src/roster-editor/src/Struct/ServerReply.elm
index 1842ea4..50a7f09 100644
--- a/src/roster-editor/src/Struct/ServerReply.elm
+++ b/src/roster-editor/src/Struct/ServerReply.elm
@@ -18,6 +18,7 @@ import Struct.Weapon
type Type =
Okay
| Disconnected
+ | GoTo String
| SetInventory Struct.Inventory.Type
| AddArmor Struct.Armor.Type
| AddGlyph Struct.Glyph.Type
diff --git a/src/roster-editor/src/Update/HandleServerReply.elm b/src/roster-editor/src/Update/HandleServerReply.elm
index 7392781..0836a76 100644
--- a/src/roster-editor/src/Update/HandleServerReply.elm
+++ b/src/roster-editor/src/Update/HandleServerReply.elm
@@ -84,6 +84,20 @@ disconnected current_state =
]
)
+goto : (
+ String ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
+ )
+goto url current_state =
+ let (model, cmds) = current_state in
+ (
+ model,
+ [
+ (Action.Ports.go_to (Constants.IO.base_url ++ "/" ++ url))
+ ]
+ )
+
add_armor : (
Struct.Armor.Type ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
@@ -159,6 +173,8 @@ apply_command command current_state =
case command of
Struct.ServerReply.Disconnected -> (disconnected current_state)
+ (Struct.ServerReply.GoTo url) -> (goto url current_state)
+
(Struct.ServerReply.AddWeapon wp) ->
(add_weapon wp current_state)
@@ -180,6 +196,7 @@ apply_command command current_state =
(Struct.ServerReply.AddCharacter char) ->
(add_character char current_state)
+
Struct.ServerReply.Okay ->
let (model, cmds) = current_state in
(
diff --git a/src/shared/elm/Comm/GoTo.elm b/src/shared/elm/Comm/GoTo.elm
new file mode 100644
index 0000000..ea8d7af
--- /dev/null
+++ b/src/shared/elm/Comm/GoTo.elm
@@ -0,0 +1,27 @@
+module Comm.GoTo exposing (decode)
+
+-- Elm -------------------------------------------------------------------------
+import Json.Decode
+
+-- ??? -------------------------------------------------------------------------
+import Struct.ServerReply
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+internal_decoder : String -> Struct.ServerReply.Type
+internal_decoder url = (Struct.ServerReply.GoTo url)
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+decode : (Json.Decode.Decoder Struct.ServerReply.Type)
+decode =
+ (Json.Decode.map
+ (internal_decoder)
+ (Json.Decode.field "url" (Json.Decode.string))
+ )