matterhorn 50200.1.0 → 50200.1.1
raw patch · 4 files changed
+46/−32 lines, 4 filesdep ~brick
Dependency ranges changed: brick
Files
- CHANGELOG.md +7/−0
- matterhorn.cabal +3/−3
- src/Events/ManageAttachments.hs +35/−28
- src/Types.hs +1/−1
CHANGELOG.md view
@@ -1,4 +1,11 @@ +50200.1.1+=========++Bug fixes:+ * The file browser now deals gracefully with directories containing+ broken symlinks.+ 50200.1.0 =========
matterhorn.cabal view
@@ -1,5 +1,5 @@ name: matterhorn-version: 50200.1.0+version: 50200.1.1 synopsis: Terminal client for the Mattermost chat system description: This is a terminal client for the Mattermost chat system. Please see the README for a list of@@ -134,7 +134,7 @@ , config-ini >= 0.2.2.0 && < 0.3 , process >= 1.4 && < 1.7 , microlens-platform >= 0.3 && < 0.4- , brick >= 0.42.1 && < 0.43+ , brick >= 0.43 && < 0.44 , brick-skylighting >= 0.2 && < 0.4 , vty >= 5.23.1 && < 5.26 , word-wrap >= 0.4.0 && < 0.5@@ -183,7 +183,7 @@ hs-source-dirs: src, test build-depends: base >=4.7 && <5 , base-compat >= 0.9 && < 0.11- , brick >= 0.42.1 && < 0.43+ , brick >= 0.43 && < 0.44 , bytestring >= 0.10 && < 0.11 , cheapskate >= 0.1 && < 0.2 , checkers >= 0.4 && < 0.5
src/Events/ManageAttachments.hs view
@@ -14,6 +14,7 @@ import qualified Brick.Widgets.FileBrowser as FB import qualified Brick.Widgets.List as L import qualified Data.ByteString as BS+import qualified Data.Text as T import qualified Data.Vector as Vector import qualified Graphics.Vty as V import Lens.Micro.Platform ( (%=), to )@@ -82,6 +83,12 @@ True -> handleFileBrowserEvent e + b' <- use (csEditState.cedFileBrowser)+ case FB.fileBrowserException b' of+ Nothing -> return ()+ Just ex -> do+ mhLog LogError $ T.pack $ "FileBrowser exception: " <> show ex+ cancelAttachmentBrowse :: MH () cancelAttachmentBrowse = do es <- use (csEditState.cedAttachmentList.L.listElementsL)@@ -93,35 +100,35 @@ handleFileBrowserEvent e = do mhHandleEventLensed (csEditState.cedFileBrowser) FB.handleFileBrowserEvent e b <- use (csEditState.cedFileBrowser)+ -- TODO: Check file browser exception state- case FB.fileBrowserSelection b of- Nothing -> return ()- Just entry -> do- -- Is the entry already present? If so, ignore the selection.- es <- use (csEditState.cedAttachmentList.L.listElementsL)- let matches = (== (FB.fileInfoFilePath entry)) .- FB.fileInfoFilePath .- attachmentDataFileInfo- case Vector.find matches es of- Just _ -> return ()- Nothing -> do- let path = FB.fileInfoFilePath entry- readResult <- liftIO $ E.try $ BS.readFile path- setMode ManageAttachments- case readResult of- Left (_::E.SomeException) ->- -- TODO: report the error- return ()- Right bytes -> do- let a = AttachmentData { attachmentDataFileInfo = entry- , attachmentDataBytes = bytes- }- oldIdx <- use (csEditState.cedAttachmentList.L.listSelectedL)- let newIdx = if Vector.null es- then Just 0- else oldIdx- csEditState.cedAttachmentList %= L.listReplace (Vector.snoc es a) newIdx- setMode Main+ let entries = FB.fileBrowserSelection b+ forM_ entries $ \entry -> do+ -- Is the entry already present? If so, ignore the selection.+ es <- use (csEditState.cedAttachmentList.L.listElementsL)+ let matches = (== (FB.fileInfoFilePath entry)) .+ FB.fileInfoFilePath .+ attachmentDataFileInfo+ case Vector.find matches es of+ Just _ -> return ()+ Nothing -> do+ let path = FB.fileInfoFilePath entry+ readResult <- liftIO $ E.try $ BS.readFile path+ case readResult of+ Left (_::E.SomeException) ->+ -- TODO: report the error+ return ()+ Right bytes -> do+ let a = AttachmentData { attachmentDataFileInfo = entry+ , attachmentDataBytes = bytes+ }+ oldIdx <- use (csEditState.cedAttachmentList.L.listSelectedL)+ let newIdx = if Vector.null es+ then Just 0+ else oldIdx+ csEditState.cedAttachmentList %= L.listReplace (Vector.snoc es a) newIdx++ when (not $ null entries) $ setMode Main deleteSelectedAttachment :: MH () deleteSelectedAttachment = do
src/Types.hs view
@@ -867,7 +867,7 @@ AttachmentData { attachmentDataFileInfo :: FB.FileInfo , attachmentDataBytes :: BS.ByteString }- deriving (Eq, Show, Read)+ deriving (Eq, Show) -- | The input mode. data EditMode =