| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-09-29 22:14:30 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2018-09-29 22:14:30 +0200 |
| commit | 08baf335929724e18addfc553f42fe8a3b274a42 (patch) | |
| tree | ca19d0bb21287bd2c19a3ac976653dd8a25a2cc0 /src | |
| parent | 463aca15fdeeb7fda838dcc7355d2365de5d703d (diff) | |
Adds icon notification.
There might be a browser function to make a notification, but let's go
with an icon change for now...
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) |


