| summaryrefslogtreecommitdiff | 
diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/background/src/Update/HandleServerReply.elm | 30 | ||||
| -rw-r--r-- | src/shared/Action/Ports.elm | 3 | 
2 files changed, 22 insertions, 11 deletions
| diff --git a/src/background/src/Update/HandleServerReply.elm b/src/background/src/Update/HandleServerReply.elm index 116a60c..983043d 100644 --- a/src/background/src/Update/HandleServerReply.elm +++ b/src/background/src/Update/HandleServerReply.elm @@ -7,6 +7,8 @@ import Json.Encode  import Http +import List +  -- Extension -------------------------------------------------------------------  import Action.Ports @@ -34,20 +36,28 @@ maybe_update_storage model cmds =     then        cmds     else -      ( -         (Action.Ports.set_results -            (Json.Encode.encode -               0 -               (Json.Encode.list -                  (List.map -                     (Struct.Player.encode) -                     (Array.toList model.players) +      let +         players_list = (Array.toList model.players) +      in +         ( +            (Action.Ports.set_results +               (Json.Encode.encode +                  0 +                  (Json.Encode.list +                     (List.map (Struct.Player.encode) players_list)                    )                 )              ) +            :: +            ( +               ( +                  if (List.any (Struct.Player.has_active_battles) players_list) +                  then (Action.Ports.activate_notification ()) +                  else (Action.Ports.disable_notification ()) +               ) +               :: cmds +            )           ) -         :: cmds -      )  handle_set_battles : (        ( diff --git a/src/shared/Action/Ports.elm b/src/shared/Action/Ports.elm index c14d7f4..c42ff8b 100644 --- a/src/shared/Action/Ports.elm +++ b/src/shared/Action/Ports.elm @@ -8,4 +8,5 @@ port get_results : () -> (Cmd msg)  port results_in : (String -> msg) -> (Sub msg)  port set_results : (String) -> (Cmd msg) -port set_signal : (Bool) -> (Cmd msg) +port activate_notification : () -> (Cmd msg) +port disable_notification : () -> (Cmd msg) | 


