Open room on notification click.

This commit is contained in:
2018-12-13 14:06:15 -08:00
parent 46352c429a
commit 2c7b72fba6
5 changed files with 14 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import Scylla.Login exposing (LoginResponse, Username, Password)
import Scylla.UserData exposing (UserData)
import Scylla.Route exposing (Route)
import Browser.Navigation as Nav
import Url.Builder
import Dict exposing (Dict)
import Browser
import Http
@@ -30,6 +31,7 @@ type Msg =
| ChangeLoginPassword Password -- During login screen: the password
| AttemptLogin -- During login screen, login button presed
| TryUrl Browser.UrlRequest -- User attempts to change URL
| OpenRoom String -- We try open a room
| ChangeRoute Route -- URL changes
| ChangeRoomText String String -- Change to a room's input text
| SendRoomText String -- Sends a message typed into a given room's input
@@ -41,3 +43,9 @@ type Msg =
displayName : Model -> Username -> String
displayName m s = Maybe.withDefault (senderName s) <| Maybe.andThen .displayName <| Dict.get s m.userData
roomUrl : String -> String
roomUrl s = Url.Builder.absolute [ "room", s ] []
loginUrl : String
loginUrl = Url.Builder.absolute [ "login" ] []

View File

@@ -8,4 +8,4 @@ type alias Notification =
}
port sendNotificationPort : Notification -> Cmd msg
port onNotificationClickPort : (Json.Decode.Value -> msg) -> Sub msg
port onNotificationClickPort : (String -> msg) -> Sub msg

View File

@@ -69,7 +69,7 @@ roomListElementView s jr =
let
name = Maybe.withDefault "<No Name>" <| roomName jr
in
a [ href <| Url.Builder.absolute [ "room", s ] [] ] [ text name ]
a [ href <| roomUrl s ] [ text name ]
loginView : Model -> Html Msg
loginView m = div [ class "login-wrapper" ]