diff --git a/src/Model.purs b/src/Model.purs index 6d22147..155d76f 100644 --- a/src/Model.purs +++ b/src/Model.purs @@ -31,11 +31,13 @@ data ImageError data ImageData = Unloaded String -- file ID of encrypted data + | Loading | ILoaded String -- blob url of decrypted image | IError ImageError instance showImageData :: Show ImageData where show (Unloaded fileID) = "Unloaded Image with fileID " <> fileID + show Loading = "Image loading..." show (ILoaded url) = "image: " <> url show (IError e) = "error loading image: " <> (show e) diff --git a/src/UI.purs b/src/UI.purs index 6644cd7..a2d747f 100644 --- a/src/UI.purs +++ b/src/UI.purs @@ -64,7 +64,8 @@ renderThumbnail pos image = maybe [] (backgroundUrl >>> HP.style >>> pure) (image.blurhashUrl) ) case image.thumb of - Unloaded _ -> + Unloaded _ -> [] + Loading -> [ HH.span [ HP.class_ $ ClassName "loading-msg" ] @@ -124,7 +125,8 @@ renderFocused zoom image = , HP.class_ $ ClassName "blurhash-frame" ] case image.full of - Unloaded _ -> + Unloaded _ -> [] + Loading -> [ HH.span [ HP.class_ $ ClassName "loading-msg" ] @@ -218,11 +220,15 @@ update' (Pan right) (GLoaded gal@{images, focus: Just { imageIndex }}) = Both [ pure $ DownloadImage $ (offset + newImageIndex) ] (GLoaded gal{ focus = Just {imageIndex: newImageIndex, zoom: false }}) -update' (DownloadImage indx) (GLoaded { images }) = +update' (DownloadImage indx) (GLoaded gal@{ images }) = let revisedIndex = mod indx (length images) maybeImageData = index images revisedIndex in case maybeImageData of - Just imageData -> Affect [fetchFullAction revisedIndex imageData] + Just imageData -> case modifyAt revisedIndex _{full = Loading} images of + Just newImages -> Both + [fetchFullAction revisedIndex imageData] + (GLoaded gal{ images = newImages }) + Nothing -> Modify $ GError $ UnexpectedError "Valid position asserted by index and module declared invalid by index" Nothing -> Modify $ GError $ UnexpectedError "Despite taking the modulo, still invalid index" update' _ modl = Modify modl