-- | Save the current deck to file, creating the file first if it doesn't exist.
-- If there is no current deck, do nothing.
saveDeck :: Kerchief ()
saveDeck = getDeck >>= whenJust saveDeck'
  where
    saveDeck' :: Deck -> Kerchief ()
    saveDeck' deck = do
        path <- (</> deck^.deckName) <$> getDecksDir
        io $ withBinaryFile path WriteMode (`BS.hPut` encode deck)
        ksModified .= False

-- | Save a soundbyte to disk, given its url and contents (mp3 binary).
saveDeck :: Kerchief ()
saveDeck = getDeck >>= whenJust saveDeck'
  where
    saveDeck' :: Deck -> Kerchief ()
    saveDeck' deck = do
        path <- (</> deck^.deckName) <$> getDecksDir
        io $ withBinaryFile path WriteMode (`BS.hPut` encode deck)
        ksModified .= False

-- | Save a soundbyte to disk, given its url and contents (mp3 binary).
saveDeck = getDeck >>= whenJust saveDeck'
  where
    saveDeck' :: Deck -> Kerchief ()
    saveDeck' deck = do
        path <- (</> deck^.deckName) <$> getDecksDir
        io $ withBinaryFile path WriteMode (`BS.hPut` encode deck)
        ksModified .= False

-- | Save a soundbyte to disk, given its url and contents (mp3 binary).