Skip to content

Commit

Permalink
Fix item sorter in trashed folders
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Mar 25, 2024
1 parent 7dca5b1 commit 7fc4365
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions hyperplane/item_sorter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,20 @@ def do_compare(

# Always sort trashed items by deletion date
if (
file_info1.get_attribute_object("standard::file").get_uri_scheme()
(
gfile1 := file_info1.get_attribute_object("standard::file")
).get_uri_scheme()
== "trash"
# Only if the trashed file is at the toplevel of the trash
and gfile1.get_uri().count("/") < 4
):
if (not (deletion_date1 := file_info1.get_deletion_date())) or (
not (deletion_date2 := file_info2.get_deletion_date())
):
return Gtk.Ordering.EQUAL

return self.__ordering_from_cmpfunc(
GLib.DateTime.compare(
file_info2.get_deletion_date(),
file_info1.get_deletion_date(),
)
GLib.DateTime.compare(deletion_date2, deletion_date1)
)

# Always sort recent items by date
Expand Down

0 comments on commit 7fc4365

Please sign in to comment.