summaryrefslogtreecommitdiff
path: root/Model.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Model.hs')
-rw-r--r--Model.hs3
1 files changed, 3 insertions, 0 deletions
diff --git a/Model.hs b/Model.hs
index 3554049..cf0e473 100644
--- a/Model.hs
+++ b/Model.hs
@@ -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
132newtype ItemDiffs = ItemDiffs [ItemDiff] 133newtype 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
142toUpdate :: ItemDiffs -> ([Update Item], [Update Kind]) 144toUpdate :: ItemDiffs -> ([Update Item], [Update Kind])
143toUpdate (ItemDiffs ds) = mconcat $ do 145toUpdate (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
154data WithType a = WithType { typedVal :: a, valType :: Text } 157data WithType a = WithType { typedVal :: a, valType :: Text }
155 deriving (Eq, Ord, Show, Functor) 158 deriving (Eq, Ord, Show, Functor)