From 35fa3b7583bdbf766d9829993e8c1078697fa43d Mon Sep 17 00:00:00 2001 From: Matt Miller Date: Fri, 17 Jan 2020 09:26:54 -0600 Subject: [PATCH] #76 Fixes error when deleting last item in folder. --- RELEASE_NOTES.md | 3 +++ src/Koffee/AssemblyInfo.fs | 4 ++-- src/Koffee/MainController.fs | 11 +++-------- src/Koffee/MainModel.fs | 6 ++++++ 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 578d6a4a..92841722 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,5 +1,8 @@ # Release Notes +### 0.5.2 (2020-01-17) +- #76 Fixes error when deleting the last item in a folder + ### 0.5.1 (2019-11-15) - #75 Fixes crash on startup when the Koffee AppData folder does not exist diff --git a/src/Koffee/AssemblyInfo.fs b/src/Koffee/AssemblyInfo.fs index e8fcfa02..3bdf6ca6 100644 --- a/src/Koffee/AssemblyInfo.fs +++ b/src/Koffee/AssemblyInfo.fs @@ -34,8 +34,8 @@ open System.Runtime.InteropServices // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [] -[] -[] +[] +[] do () diff --git a/src/Koffee/MainController.fs b/src/Koffee/MainController.fs index 952bbd37..8e3cfc49 100644 --- a/src/Koffee/MainController.fs +++ b/src/Koffee/MainController.fs @@ -63,12 +63,7 @@ module Nav = |> List.filter (fun i -> model.Config.ShowHidden || not i.IsHidden || String.equalsIgnoreCase selectName i.Name) |> (model.Sort |> Option.map SortField.SortByTypeThen |? id) - |> Seq.ifEmpty ( - let text = - if model.Location = Path.Network then "Remote hosts that you visit will appear here" - else "Empty folder" - [ { Item.Empty with Name = sprintf "<%s>" text; Path = model.Location } ] - ) + |> Seq.ifEmpty (Item.EmptyFolder model.Location) { model with Items = items } |> select selectType let openPath (fsReader: IFileSystemReader) path select (model: MainModel) = result { @@ -617,7 +612,7 @@ module Action = yield { model with Directory = model.Directory |> List.except [item] - Items = model.Items |> List.except [item] + Items = model.Items |> List.except [item] |> Seq.ifEmpty (Item.EmptyFolder model.Location) }.WithCursor model.Cursor |> performedAction action } @@ -628,7 +623,7 @@ module Action = yield { model with Directory = model.Directory |> List.except [model.SelectedItem] - Items = model.Items |> List.except [model.SelectedItem] + Items = model.Items |> List.except [model.SelectedItem] |> Seq.ifEmpty (Item.EmptyFolder model.Location) History = model.History.WithoutNetHost host Status = Some <| MainStatus.removedNetworkHost host }.WithCursor model.Cursor diff --git a/src/Koffee/MainModel.fs b/src/Koffee/MainModel.fs index 06f46b91..9aa6c266 100644 --- a/src/Koffee/MainModel.fs +++ b/src/Koffee/MainModel.fs @@ -58,6 +58,12 @@ with Modified = None; Size = None; IsHidden = false } + static member EmptyFolder path = + let text = + if path = Path.Network then "Remote hosts that you visit will appear here" + else "Empty folder" + [ { Item.Empty with Name = sprintf "<%s>" text; Path = path } ] + static member Basic path name itemType = { Item.Empty with Path = path