From 37062e1ca6c479b7cf773931aa0e797ebcfafe8b Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Fri, 5 Jun 2020 22:27:14 -0700 Subject: Add user datatype to keep I also restructured some types so that I could grab a handle on the keep to close it on shutdown, otherwise the database would be locked and I can't do anything about it. This might mean I have to delete and start the database from scratch when I deploy, but that's okay because I haven't stored anything yet. I also renamed some stuff like 'deck' and 'beam' just for fun. I could make these into more general interfaces like I always planned to. Also I haven't really tested this yet, so... next commit will implement the user login. --- Hero/Client.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Hero/Client.hs') diff --git a/Hero/Client.hs b/Hero/Client.hs index a513dcd..4189fd8 100644 --- a/Hero/Client.hs +++ b/Hero/Client.hs @@ -28,6 +28,7 @@ import Hero.App ComicReaderState (..), ComicReaderView (..), Model (..), + User (..), audioId, chooseExperienceLink, comicPlayerFullLink, @@ -130,12 +131,13 @@ move (ToggleZoom c pg) m = m {cpState = newState} <# pure act Reading Full _ _ -> (reading Spread, goto comicPlayerSpreadLink) Reading Spread _ _ -> (reading Full, goto comicPlayerFullLink) x -> (x, NoOp) -move (ToggleInLibrary c) model = model {userLibrary = newLib} <# pure NoOp +move (ToggleInLibrary c) model = model {user = newUser} <# pure NoOp where + newUser = (user model) { userLibrary = newLib } newLib - | c `elem` userLibrary model = - Protolude.filter (/= c) $ userLibrary model - | otherwise = c : userLibrary model + | c `elem` (userLibrary $ user model) = + Protolude.filter (/= c) $ userLibrary $ user model + | otherwise = c : (userLibrary $ user model) move (HandleURI u) model = model {uri = u} <# pure NoOp move (ChangeURI u) model = model <# do pushURI u -- cgit v1.2.3