diff options
Diffstat (limited to 'Model.hs')
-rw-r--r-- | Model.hs | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -128,6 +128,7 @@ data ItemDiff = DiffKind Text | |||
128 | | DiffBought ItemDate | 128 | | DiffBought ItemDate |
129 | | DiffExpires ItemDate | 129 | | DiffExpires ItemDate |
130 | | DiffOpened ItemDate | 130 | | DiffOpened ItemDate |
131 | | DiffRunningLow Bool | ||
131 | 132 | ||
132 | newtype ItemDiffs = ItemDiffs [ItemDiff] | 133 | newtype ItemDiffs = ItemDiffs [ItemDiff] |
133 | 134 | ||
@@ -138,6 +139,7 @@ instance FromJSON ItemDiffs where | |||
138 | tell =<< maybe [] (pure . DiffBought) <$> lift (obj .:! "bought") | 139 | tell =<< maybe [] (pure . DiffBought) <$> lift (obj .:! "bought") |
139 | tell =<< maybe [] (pure . DiffExpires) <$> lift (obj .:! "expires") | 140 | tell =<< maybe [] (pure . DiffExpires) <$> lift (obj .:! "expires") |
140 | tell =<< maybe [] (pure . DiffOpened) <$> lift (obj .:! "opened") | 141 | tell =<< maybe [] (pure . DiffOpened) <$> lift (obj .:! "opened") |
142 | tell =<< maybe [] (pure . DiffRunningLow) <$> lift (obj .:? "running-low") | ||
141 | 143 | ||
142 | toUpdate :: ItemDiffs -> ([Update Item], [Update Kind]) | 144 | toUpdate :: ItemDiffs -> ([Update Item], [Update Kind]) |
143 | toUpdate (ItemDiffs ds) = mconcat $ do | 145 | toUpdate (ItemDiffs ds) = mconcat $ do |
@@ -150,6 +152,7 @@ toUpdate (ItemDiffs ds) = mconcat $ do | |||
150 | DiffBought d -> (, []) [ ItemBought =. d ] | 152 | DiffBought d -> (, []) [ ItemBought =. d ] |
151 | DiffExpires d -> (, []) [ ItemExpires =. d ] | 153 | DiffExpires d -> (, []) [ ItemExpires =. d ] |
152 | DiffOpened d -> (, []) [ ItemOpened =. d ] | 154 | DiffOpened d -> (, []) [ ItemOpened =. d ] |
155 | DiffRunningLow b -> (, []) [ ItemRunningLow =. b ] | ||
153 | 156 | ||
154 | data WithType a = WithType { typedVal :: a, valType :: Text } | 157 | data WithType a = WithType { typedVal :: a, valType :: Text } |
155 | deriving (Eq, Ord, Show, Functor) | 158 | deriving (Eq, Ord, Show, Functor) |