blob: 2ff739f363ff4a1de68831bbb47c3b18bd768570 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
module Update.RefreshBattles exposing (apply_to)
-- Elm -------------------------------------------------------------------------
import Array
-- Extension -------------------------------------------------------------------
import Comm.GetBattles
import Struct.Event
import Struct.Flags
import Struct.Model
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
apply_to : Struct.Model.Type -> (Struct.Model.Type, (Cmd Struct.Event.Type))
apply_to model =
case (Array.get 0 model.players) of
Nothing -> (model, Cmd.none)
(Just player) ->
case (Comm.GetBattles.try model player) of
-- TODO: Invalidate only this player, refresh the others.
Nothing -> (model, Cmd.none)
(Just cmd) -> ({model | query_index = 0}, cmd)
|