Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Recycle Bin changing icons in the side bar #10113

Conversation

QuaintMako
Copy link
Contributor

Resolved / Related Issues
Items resolved / related issues by this PR.

What have been done

  • An event is now raised when the recycle bin is modified.
  • A new icon for the empty recycle bin has been indexed.
  • A light refactoring in src/Files.App/DataModels/SidebarPinnedModel.cs has been done to the function AddItemToSidebarAsync.

Validation
How did you test these changes?

  • Built and ran the app
  • Tested the changes for accessibility

Screenshots (optional)

When the recycle bin is empty:
empty

When the recycle bin is not empty:
filled

@yaira2 yaira2 changed the title Feature: Recycle Bin changing icons in the side bar. Feature: Recycle Bin changing icons in the side bar Oct 9, 2022
src/Files.App/DataModels/SidebarPinnedModel.cs Outdated Show resolved Hide resolved
@@ -76,6 +80,7 @@ public async Task EmptyRecycleBin()
if (result == ContentDialogResult.Primary)
{
Shell32.SHEmptyRecycleBin(IntPtr.Zero, null, Shell32.SHERB.SHERB_NOCONFIRMATION | Shell32.SHERB.SHERB_NOPROGRESSUI);
RaiseRecycleBinChangedEvent();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use null check

RecycleBinChanged?.Invoke(null, null);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed inside the function that handles the event raising. But would you rather have the event raised directly without any method maybe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. There's no need for additional method to raise this event

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actuallty do need it to raise the event outside of the class. We need to raise it from RestoreItemsFromTrashAsync and DeleteItemsAsync from FilesystemHelpers.cs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@d2dyno1 Should I do something to indeed remove the need of the method entirely or should it stay that way?

Removing it would means to move methods from the FileSystemHelpers to the RecycleBinHelpers, albeit it wouldn't be their optimal locations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think moving it would make sense (?). In addition, it should be moved to instantiable helper (because it exposes an event) but that'd be part of a bigger refactor out of scope for this PR.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that moving it is better and good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to actually implement this. I have been turning the issue in my head for the past few days, but I cannot find a solution that feels actually clean for it. Consider this message as a formal request for help.

After giving it some thoughts, the methods from FilesystemHelpers.cs should not be moved. They are in their right places, they are not only linked to the recycle bin.

A possibility would to raise events in FilesystemHelpers.cs when Delete or Restore are called, and have methods to update the recycle bin icon subscribe to them. But then, an issue comes from the RecycleBinHelpers.EmptyRecycleBin() method that does not use the Delete method to clear the recycle bin.

I must be missing something obvious, and I'd like to see this PR through.

src/Files.App/Helpers/UIHelpers.cs Outdated Show resolved Hide resolved
src/Files.App/ViewModels/SidebarViewModel.cs Outdated Show resolved Hide resolved
src/Files.App/ViewModels/SidebarViewModel.cs Show resolved Hide resolved
@d2dyno1
Copy link
Member

d2dyno1 commented Oct 14, 2022

@QuaintMako Could you resolve conflicts before it's merged?

@QuaintMako QuaintMako marked this pull request as draft October 24, 2022 13:34
@QuaintMako
Copy link
Contributor Author

Marking that PR as a draft for now, I won't be able to take care of it for a few days.

@QuaintMako
Copy link
Contributor Author

Would it be possible to get a help requested label on this PR please?

@Josh65-2201 Josh65-2201 added the help wanted Extra attention is needed label Oct 26, 2022
@QuaintMako
Copy link
Contributor Author

After discussions with Yair on Discord, I'm closing this PR for now. Waiting for the big refactoring coming up soon, which should solve the event issue.

@QuaintMako QuaintMako closed this Oct 27, 2022
@QuaintMako QuaintMako deleted the 9195_DifferentIconSideBarRecycleBinState branch July 2, 2023 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed needs - code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Use different icon to indicate whether the Recycle Bin is empty or not.
5 participants