@@ -27,10 +27,12 @@ main =
2727 ( { error = ""
2828 , entries = Nothing
2929 , newEntry = ""
30+ , shipName = Nothing
3031 }
3132 , Cmd.batch
3233 [ Ur.logIn "http://localhost:8080" "lidlut-tabwed-pillex-ridrup"
3334 |> Cmd.map (result (Debug.toString >> Error) (always Noop))
35+ , Ur.getShipName "http://localhost:8080" |> Cmd.map (result (always Noop) GotShipName)
3436 , Ur.Requests.scry
3537 { url = "http://localhost:8080"
3638 , agent = "journal"
@@ -51,18 +53,18 @@ main =
5153 , subscriptions = always Sub.none
5254 , createEventSource = createEventSource
5355 , urbitSubscriptions =
54− \{ entries } ->
55− case entries of
56− Nothing ->
57− Ur.Sub.none
58−
59− Just _ ->
56+ \{ entries, shipName } ->
57+ case ( entries, shipName ) of
58+ ( Just _, Just ship ) ->
6059 Ur.Sub.subscribe
61− { ship = "~zod"
60+ { ship = ship
6261 , app = "journal"
6362 , path = [ "updates" ]
6463 , deconstructor = decodeJournalUpdate |> D.map GotUpdate
6564 }
65+
66+ _ ->
67+ Ur.Sub.none
6668 , onEventSourceMsg = onEventSourceMessage
6769 , onUrlChange = \_ -> Noop
6870 , onUrlRequest = \_ -> Noop
@@ -74,6 +76,7 @@ type alias Model =
7476 { error : String
7577 , entries : Maybe (List ( BigInt, String ))
7678 , newEntry : String
79+ , shipName : Maybe String
7780 }
7881
7982
@@ -86,6 +89,7 @@ type Msg
8689 | DeleteEntry BigInt
8790 | AddEntry String
8891 | RunCmd (Ur.Cmd.Cmd Msg)
92+ | GotShipName String
8993
9094
9195update : Msg -> Model -> ( Model, Ur.Cmd.Cmd Msg )
@@ -158,6 +162,9 @@ update msg model =
158162 RunCmd cmd ->
159163 ( model, cmd )
160164
165+ GotShipName name ->
166+ ( { model | shipName = Just name }, Ur.Cmd.none )
167+
161168
162169type JournalUpdate
163170 = Add BigInt String