Skip to content

Commit

Permalink
Fix: Fixed crash that would occur when deleting or restoring files (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofranzen99 authored Aug 14, 2023
1 parent 001e8eb commit 6e37d69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 12 additions & 3 deletions src/Files.App/Data/Items/LocationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public bool IsExpanded
public bool IsHeader { get; set; }

private object toolTip = "";
public object ToolTip
public virtual object ToolTip
{
get => toolTip;
set
Expand All @@ -109,7 +109,10 @@ public class RecycleBinLocationItem : LocationItem
{
public void RefreshSpaceUsed(object sender, FileSystemEventArgs e)
{
SpaceUsed = RecycleBinHelpers.GetSize();
MainWindow.Instance.DispatcherQueue.TryEnqueue(() =>
{
SpaceUsed = RecycleBinHelpers.GetSize();
});
}

private ulong spaceUsed;
Expand All @@ -118,10 +121,16 @@ public ulong SpaceUsed
get => spaceUsed;
set
{
SetProperty(ref spaceUsed, value);
if (SetProperty(ref spaceUsed, value))
OnPropertyChanged(nameof(ToolTip));
}
}

public override object ToolTip
{
get => SpaceUsed.ToSizeString();
}

public RecycleBinLocationItem()
{
SpaceUsed = RecycleBinHelpers.GetSize();
Expand Down
5 changes: 0 additions & 5 deletions src/Files.App/Data/Models/SidebarPinnedModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ public async Task<LocationItem> CreateLocationItemFromPathAsync(string path)
locationItem.IsDefaultLocation = false;
locationItem.Text = res.Result?.DisplayName ?? Path.GetFileName(path.TrimEnd('\\'));

if(locationItem is RecycleBinLocationItem recycleBinItem)
{
recycleBinItem.ToolTip = recycleBinItem.SpaceUsed.ToSizeString();
}

if (res || (FilesystemResult)FolderHelpers.CheckFolderAccessWithWin32(path))
{
locationItem.IsInvalid = false;
Expand Down

0 comments on commit 6e37d69

Please sign in to comment.