Open room on notification click.
This commit is contained in:
parent
46352c429a
commit
2c7b72fba6
|
@ -59,6 +59,7 @@ update msg model = case msg of
|
|||
ChangeLoginPassword p -> ({ model | loginPassword = p }, Cmd.none)
|
||||
AttemptLogin -> (model, Scylla.Http.login model.apiUrl model.loginUsername model.loginPassword) -- TODO
|
||||
TryUrl urlRequest -> updateTryUrl model urlRequest
|
||||
OpenRoom s -> (model, Nav.pushUrl model.key <| roomUrl s)
|
||||
ChangeRoute r -> ({ model | route = r }, Cmd.none)
|
||||
ReceiveLoginResponse r -> updateLoginResponse model r
|
||||
ReceiveFirstSyncResponse r -> updateSyncResponse model r False
|
||||
|
@ -129,7 +130,7 @@ updateSyncResponse model r notify =
|
|||
_ -> (model, syncCmd)
|
||||
|
||||
subscriptions : Model -> Sub Msg
|
||||
subscriptions m = Sub.none
|
||||
subscriptions m = onNotificationClickPort OpenRoom
|
||||
|
||||
onUrlRequest : Browser.UrlRequest -> Msg
|
||||
onUrlRequest = TryUrl
|
||||
|
|
|
@ -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" ] []
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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" ]
|
||||
|
|
|
@ -9,9 +9,8 @@ function setupNotificationPorts(app) {
|
|||
}
|
||||
var n = new Notification(data.name, options)
|
||||
n.onclick = function() {
|
||||
app.ports.onNotificationClickPort.send({
|
||||
"room" : data.room
|
||||
});
|
||||
app.ports.onNotificationClickPort.send(data.room);
|
||||
n.close();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user