diff --git a/.gitignore b/.gitignore index 24f5915..726cf85 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .DS_Store /postgres-data *.pyc +aion/web/static/assets/images/ package-lock.json diff --git a/aion/mix.lock b/aion/mix.lock index d56acd1..8d6b20b 100644 --- a/aion/mix.lock +++ b/aion/mix.lock @@ -1,25 +1,25 @@ -%{"addict": {:hex, :addict, "0.3.0", "8cbf72bb80abe5cc2934dea1fa601eb4f7fd7fa9ea6869c9e47d24289a939d22", [:mix], [{:comeonin, "~> 2.1", [hex: :comeonin, repo: "hexpm", optional: false]}, {:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: false]}, {:ecto, "~> 2.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:mailgun, "~> 0.1", [hex: :mailgun, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.1", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"}, - "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], [], "hexpm"}, - "comeonin": {:hex, :comeonin, "2.6.0", "74c288338b33205f9ce97e2117bb9a2aaab103a1811d243443d76fdb62f904ac", [:make, :mix], [], "hexpm"}, - "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], [], "hexpm"}, - "cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm"}, - "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], [], "hexpm"}, - "credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}], "hexpm"}, - "db_connection": {:hex, :db_connection, "1.1.2", "2865c2a4bae0714e2213a0ce60a1b12d76a6efba0c51fbda59c9ab8d1accc7a8", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, repo: "hexpm", optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, - "decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], [], "hexpm"}, - "ecto": {:hex, :ecto, "2.1.4", "d1ba932813ec0e0d9db481ef2c17777f1cefb11fc90fa7c142ff354972dfba7e", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, repo: "hexpm", optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, repo: "hexpm", optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, repo: "hexpm", optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, repo: "hexpm", optional: true]}], "hexpm"}, - "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], [], "hexpm"}, - "gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], [], "hexpm"}, +%{"addict": {:hex, :addict, "0.3.0", "8cbf72bb80abe5cc2934dea1fa601eb4f7fd7fa9ea6869c9e47d24289a939d22", [:mix], [{:comeonin, "~> 2.1", [hex: :comeonin, optional: false]}, {:cowboy, "~> 1.0", [hex: :cowboy, optional: false]}, {:ecto, "~> 2.0", [hex: :ecto, optional: false]}, {:mailgun, "~> 0.1", [hex: :mailgun, optional: false]}, {:phoenix, "~> 1.1", [hex: :phoenix, optional: false]}]}, + "bunt": {:hex, :bunt, "0.2.0", "951c6e801e8b1d2cbe58ebbd3e616a869061ddadcc4863d0a2182541acae9a38", [:mix], []}, + "comeonin": {:hex, :comeonin, "2.6.0", "74c288338b33205f9ce97e2117bb9a2aaab103a1811d243443d76fdb62f904ac", [:make, :mix], []}, + "connection": {:hex, :connection, "1.0.4", "a1cae72211f0eef17705aaededacac3eb30e6625b04a6117c1b2db6ace7d5976", [:mix], []}, + "cowboy": {:hex, :cowboy, "1.1.2", "61ac29ea970389a88eca5a65601460162d370a70018afe6f949a29dca91f3bb0", [:rebar3], [{:cowlib, "~> 1.0.2", [hex: :cowlib, optional: false]}, {:ranch, "~> 1.3.2", [hex: :ranch, optional: false]}]}, + "cowlib": {:hex, :cowlib, "1.0.2", "9d769a1d062c9c3ac753096f868ca121e2730b9a377de23dec0f7e08b1df84ee", [:make], []}, + "credo": {:hex, :credo, "0.8.4", "4e50acac058cf6292d6066e5b0d03da5e1483702e1ccde39abba385c9f03ead4", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, optional: false]}]}, + "db_connection": {:hex, :db_connection, "1.1.2", "2865c2a4bae0714e2213a0ce60a1b12d76a6efba0c51fbda59c9ab8d1accc7a8", [:mix], [{:connection, "~> 1.0.2", [hex: :connection, optional: false]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]}, + "decimal": {:hex, :decimal, "1.4.0", "fac965ce71a46aab53d3a6ce45662806bdd708a4a95a65cde8a12eb0124a1333", [:mix], []}, + "ecto": {:hex, :ecto, "2.1.4", "d1ba932813ec0e0d9db481ef2c17777f1cefb11fc90fa7c142ff354972dfba7e", [:mix], [{:db_connection, "~> 1.1", [hex: :db_connection, optional: true]}, {:decimal, "~> 1.2", [hex: :decimal, optional: false]}, {:mariaex, "~> 0.8.0", [hex: :mariaex, optional: true]}, {:poison, "~> 2.2 or ~> 3.0", [hex: :poison, optional: true]}, {:poolboy, "~> 1.5", [hex: :poolboy, optional: false]}, {:postgrex, "~> 0.13.0", [hex: :postgrex, optional: true]}, {:sbroker, "~> 1.0", [hex: :sbroker, optional: true]}]}, + "fs": {:hex, :fs, "0.9.2", "ed17036c26c3f70ac49781ed9220a50c36775c6ca2cf8182d123b6566e49ec59", [:rebar], []}, + "gettext": {:hex, :gettext, "0.13.1", "5e0daf4e7636d771c4c71ad5f3f53ba09a9ae5c250e1ab9c42ba9edccc476263", [:mix], []}, "mailgun": {:git, "https://github.com/chrismccord/mailgun.git", "ace116f37a86b3b11cecad6f37c4599f4552452b", [branch: "master"]}, - "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], [], "hexpm"}, - "phoenix": {:hex, :phoenix, "1.2.5", "dbc45a5f8fb522aaa815b003f2d5598bc45e23102ae3e265768848ab23eafcb7", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.3.3 or ~> 1.2.4 or ~> 1.1.8 or ~> 1.0.5", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_ecto": {:hex, :phoenix_ecto, "3.2.3", "450c749876ff1de4a78fdb305a142a76817c77a1cd79aeca29e5fc9a6c630b26", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_html": {:hex, :phoenix_html, "2.10.2", "0249cc636c9fb4ac4c84a6075e3e352ca5e31fd4756142bc9e31d73fd507a62a", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.0.8", "4333f9c74190f485a74866beff2f9304f069d53f047f5fbb0fb8d1ee4c495f73", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2-rc", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm"}, - "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], [], "hexpm"}, - "plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}], "hexpm"}, - "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], [], "hexpm"}, - "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"}, - "postgrex": {:hex, :postgrex, "0.13.3", "c277cfb2a9c5034d445a722494c13359e361d344ef6f25d604c2353185682bfc", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm"}, - "ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], [], "hexpm"}, - "simetric": {:hex, :simetric, "0.1.0", "709b1dcbfe2e8ce24bc1892c4ab3f1a101d22253ec413b8c7f16c206cd6b6baa", [:mix], [], "hexpm"}} + "mime": {:hex, :mime, "1.1.0", "01c1d6f4083d8aa5c7b8c246ade95139620ef8effb009edde934e0ec3b28090a", [:mix], []}, + "phoenix": {:hex, :phoenix, "1.2.5", "dbc45a5f8fb522aaa815b003f2d5598bc45e23102ae3e265768848ab23eafcb7", [:mix], [{:cowboy, "~> 1.0", [hex: :cowboy, optional: true]}, {:phoenix_pubsub, "~> 1.0", [hex: :phoenix_pubsub, optional: false]}, {:plug, "~> 1.3.3 or ~> 1.2.4 or ~> 1.1.8 or ~> 1.0.5", [hex: :plug, optional: false]}, {:poison, "~> 1.5 or ~> 2.0", [hex: :poison, optional: false]}]}, + "phoenix_ecto": {:hex, :phoenix_ecto, "3.2.3", "450c749876ff1de4a78fdb305a142a76817c77a1cd79aeca29e5fc9a6c630b26", [:mix], [{:ecto, "~> 2.1", [hex: :ecto, optional: false]}, {:phoenix_html, "~> 2.9", [hex: :phoenix_html, optional: true]}, {:plug, "~> 1.0", [hex: :plug, optional: false]}]}, + "phoenix_html": {:hex, :phoenix_html, "2.10.2", "0249cc636c9fb4ac4c84a6075e3e352ca5e31fd4756142bc9e31d73fd507a62a", [:mix], [{:plug, "~> 1.0", [hex: :plug, optional: false]}]}, + "phoenix_live_reload": {:hex, :phoenix_live_reload, "1.0.8", "4333f9c74190f485a74866beff2f9304f069d53f047f5fbb0fb8d1ee4c495f73", [:mix], [{:fs, "~> 0.9.1", [hex: :fs, optional: false]}, {:phoenix, "~> 1.0 or ~> 1.2-rc", [hex: :phoenix, optional: false]}]}, + "phoenix_pubsub": {:hex, :phoenix_pubsub, "1.0.2", "bfa7fd52788b5eaa09cb51ff9fcad1d9edfeb68251add458523f839392f034c1", [:mix], []}, + "plug": {:hex, :plug, "1.3.5", "7503bfcd7091df2a9761ef8cecea666d1f2cc454cbbaf0afa0b6e259203b7031", [:mix], [{:cowboy, "~> 1.0.1 or ~> 1.1", [hex: :cowboy, optional: true]}, {:mime, "~> 1.0", [hex: :mime, optional: false]}]}, + "poison": {:hex, :poison, "2.2.0", "4763b69a8a77bd77d26f477d196428b741261a761257ff1cf92753a0d4d24a63", [:mix], []}, + "poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], []}, + "postgrex": {:hex, :postgrex, "0.13.3", "c277cfb2a9c5034d445a722494c13359e361d344ef6f25d604c2353185682bfc", [:mix], [{:connection, "~> 1.0", [hex: :connection, optional: false]}, {:db_connection, "~> 1.1", [hex: :db_connection, optional: false]}, {:decimal, "~> 1.0", [hex: :decimal, optional: false]}]}, + "ranch": {:hex, :ranch, "1.3.2", "e4965a144dc9fbe70e5c077c65e73c57165416a901bd02ea899cfd95aa890986", [:rebar3], []}, + "simetric": {:hex, :simetric, "0.1.0", "709b1dcbfe2e8ce24bc1892c4ab3f1a101d22253ec413b8c7f16c206cd6b6baa", [:mix], []}} diff --git a/aion/web/channels/subject_channel.ex b/aion/web/channels/subject_channel.ex index a1d9550..d38599d 100644 --- a/aion/web/channels/subject_channel.ex +++ b/aion/web/channels/subject_channel.ex @@ -64,9 +64,9 @@ defmodule Aion.SubjectChannel do defp send_feedback(socket, evaluation) do feedback = cond do - evaluation == 1.0 -> "Correct!" - evaluation > 0.8 -> "Close one!" - true -> "Wrong answer." + evaluation == 1.0 -> :correct + evaluation > 0.8 -> :close + true -> :incorrect end push socket, "answer:feedback", %{"feedback" => feedback} diff --git a/aion/web/elm/elm-package.json b/aion/web/elm/elm-package.json index 6793fa9..186b6b6 100644 --- a/aion/web/elm/elm-package.json +++ b/aion/web/elm/elm-package.json @@ -17,7 +17,8 @@ "evancz/url-parser": "2.0.1 <= v < 3.0.0", "fbonetti/elm-phoenix-socket": "2.2.0 <= v <= 2.2.0", "krisajenkins/remotedata": "4.3.0 <= v < 5.0.0", - "lgastako/elm-select": "2.0.0 <= v < 3.0.0" + "lgastako/elm-select": "2.0.0 <= v < 3.0.0", + "pablen/toasty": "1.0.4 <= v <= 1.0.4" }, "elm-version": "0.18.0 <= v < 0.19.0" } diff --git a/aion/web/elm/src/General/Models.elm b/aion/web/elm/src/General/Models.elm index 62efadc..45e8bfa 100644 --- a/aion/web/elm/src/General/Models.elm +++ b/aion/web/elm/src/General/Models.elm @@ -5,6 +5,8 @@ import Panel.Models exposing (PanelData) import Phoenix.Socket import RemoteData exposing (WebData) import Room.Models exposing (RoomId, RoomsData, UsersInRoom, QuestionInRoom, UserGameData) +import Toasty +import Toasty.Defaults import User.Models exposing (CurrentUser) @@ -18,6 +20,7 @@ type alias Model = , userGameData : UserGameData , questionInChannel : QuestionInRoom , roomId : RoomId + , toasties : Toasty.Stack Toasty.Defaults.Toast , panelData : PanelData } @@ -51,6 +54,7 @@ initialModel flags route = , image_name = "" } , roomId = 0 + , toasties = Toasty.initialState , panelData = { newQuestionContent = "" , newAnswerContent = "" diff --git a/aion/web/elm/src/Msgs.elm b/aion/web/elm/src/Msgs.elm index 7757e0b..66705e0 100644 --- a/aion/web/elm/src/Msgs.elm +++ b/aion/web/elm/src/Msgs.elm @@ -7,6 +7,8 @@ import RemoteData exposing (WebData) import Phoenix.Socket import Json.Encode as Encode import Room.Models exposing (RoomId, RoomsData) +import Toasty +import Toasty.Defaults import User.Models exposing (CurrentUser) @@ -24,6 +26,7 @@ type Msg | KeyDown Int | NoOperation | ReceiveAnswerFeedback Encode.Value + | ToastyMsg (Toasty.Msg Toasty.Defaults.Toast) | SetNewQuestionContent String | SetNewAnswerContent String | SetNewAnswerCategory String diff --git a/aion/web/elm/src/Room/Models.elm b/aion/web/elm/src/Room/Models.elm index fd941a0..3deb87a 100644 --- a/aion/web/elm/src/Room/Models.elm +++ b/aion/web/elm/src/Room/Models.elm @@ -30,8 +30,7 @@ type alias UserList = type alias UserGameData = - { currentAnswer : String - } + { currentAnswer : String } type alias QuestionInRoom = diff --git a/aion/web/elm/src/Room/Notifications.elm b/aion/web/elm/src/Room/Notifications.elm new file mode 100644 index 0000000..163c600 --- /dev/null +++ b/aion/web/elm/src/Room/Notifications.elm @@ -0,0 +1,32 @@ +module Room.Notifications exposing (..) + +import General.Models exposing (Model) +import Msgs exposing (Msg(..)) +import Toasty +import Toasty.Defaults + + +myConfig : Toasty.Config Msg +myConfig = + Toasty.Defaults.config + |> Toasty.delay 5000 + + +addToast : Toasty.Defaults.Toast -> ( Model, Cmd Msg ) -> ( Model, Cmd Msg ) +addToast toast ( model, cmd ) = + Toasty.addToast myConfig ToastyMsg toast ( model, cmd ) + + +incorrectAnswerToast : ( Model, Cmd Msg ) -> ( Model, Cmd Msg ) +incorrectAnswerToast = + addToast (Toasty.Defaults.Error "Error!" "Wrong Answer") + + +closeAnswerToast : ( Model, Cmd Msg ) -> ( Model, Cmd Msg ) +closeAnswerToast = + addToast (Toasty.Defaults.Warning "Close one!" "Your Answer is Almost Correct") + + +correctAnswerToast : ( Model, Cmd Msg ) -> ( Model, Cmd Msg ) +correctAnswerToast = + addToast (Toasty.Defaults.Success "Good Answer!" "Your Answer is Correct") diff --git a/aion/web/elm/src/Room/View.elm b/aion/web/elm/src/Room/View.elm index a66d0d3..e22b341 100644 --- a/aion/web/elm/src/Room/View.elm +++ b/aion/web/elm/src/Room/View.elm @@ -2,16 +2,17 @@ module Room.View exposing (..) import General.Models exposing (Model) import Html exposing (Attribute, Html, a, button, div, form, input, li, text, ul) -import Html.Attributes exposing (href, id, type_, value) +import Html.Attributes exposing (href, src, id, type_, value) import Html.Events exposing (keyCode, on, onClick, onInput, onWithOptions) -import Room.Utils exposing (getRoomList, getRoomNameById) -import Msgs exposing (Msg(KeyDown, NoOperation, SetAnswer, SubmitAnswer)) -import Html exposing (Html, a, div, img, li, p, text, ul) -import Html.Attributes exposing (href, src) -import Msgs exposing (Msg) -import Room.Models exposing (Answer, ImageName, RoomId, RoomsData, UserGameData, UserInRoomRecord, answerInputFieldId) import Json.Decode exposing (map) +import Msgs exposing (Msg(..)) +import Html exposing (Html, a, div, img, li, p, text, ul) import Room.Constants exposing (defaultImagePath, imagesPath) +import Room.Models exposing (Answer, ImageName, RoomId, RoomsData, UserGameData, UserInRoomRecord, answerInputFieldId) +import Room.Utils exposing (getRoomList, getRoomNameById) +import Room.Notifications exposing (myConfig) +import Toasty +import Toasty.Defaults roomView : Model -> RoomId -> Html Msg @@ -32,6 +33,7 @@ roomView model roomId = , p [] [ text model.questionInChannel.content ] , displayQuestionImage imageName , displayAnswerInput currentAnswer + , Toasty.view myConfig Toasty.Defaults.view ToastyMsg model.toasties ] diff --git a/aion/web/elm/src/Update.elm b/aion/web/elm/src/Update.elm index 4afd4d7..06f00a1 100644 --- a/aion/web/elm/src/Update.elm +++ b/aion/web/elm/src/Update.elm @@ -4,17 +4,19 @@ import Dom exposing (focus) import General.Models exposing (Model, Route(RoomRoute)) import General.Utils exposing (getSubjectIdByName) import Json.Decode as Decode +import Json.Encode as Encode import Msgs exposing (Msg(..)) import Panel.Api exposing (createQuestionWithAnswers) +import Phoenix.Channel +import Phoenix.Push +import Phoenix.Socket import Room.Constants exposing (enterKeyCode) import Room.Decoders exposing (answerFeedbackDecoder, questionDecoder, usersListDecoder) import Room.Models exposing (RoomsData, answerInputFieldId) +import Room.Notifications exposing (..) import Routing exposing (parseLocation) -import Phoenix.Socket -import Phoenix.Channel -import Phoenix.Push -import Json.Encode as Encode import Task +import Toasty update : Msg -> Model -> ( Model, Cmd Msg ) @@ -51,7 +53,7 @@ update msg model = |> Phoenix.Socket.on "answer:feedback" ("rooms:" ++ roomIdToString) ReceiveAnswerFeedback ) in - { model | socket = socket, route = newRoute, roomId = roomId } ! [ Cmd.map PhoenixMsg cmd ] + { model | socket = socket, route = newRoute, roomId = roomId, toasties = Toasty.initialState } ! [ Cmd.map PhoenixMsg cmd ] _ -> { model | route = newRoute } ! [] @@ -75,10 +77,21 @@ update msg model = case Decode.decodeValue answerFeedbackDecoder rawFeedback of Ok answerFeedback -> let - x = - Debug.log "feedback" answerFeedback.feedback + answerToast = + case answerFeedback.feedback of + "incorrect" -> + incorrectAnswerToast + + "close" -> + closeAnswerToast + + "correct" -> + correctAnswerToast + + _ -> + Debug.crash "Unexpected Feedback" in - model ! [] + answerToast (model ! []) Err error -> model ! [] @@ -98,6 +111,7 @@ update msg model = push_ = Phoenix.Push.init "new:answer" ("rooms:" ++ (toString model.roomId)) |> Phoenix.Push.withPayload payload + |> Phoenix.Push.onOk (\rawFeedback -> ReceiveAnswerFeedback rawFeedback) ( socket, cmd ) = Phoenix.Socket.push push_ model.socket @@ -124,6 +138,9 @@ update msg model = NoOperation -> model ! [] + ToastyMsg subMsg -> + Toasty.update myConfig ToastyMsg subMsg model + SetNewQuestionContent questionContent -> let oldPanelData =