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

Support for collections in trash #1013

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

michalrentka
Copy link
Contributor

No description provided.

Copy link
Contributor

@mvasilak mvasilak left a comment

Choose a reason for hiding this comment

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

When tapping an item w/ an attachment in trash it doesn't open it.

There some other minor omissions and comments for discussion.

Zotero/Scenes/Detail/Items/Views/ItemsViewController.swift Outdated Show resolved Hide resolved
Zotero/Scenes/Detail/DetailCoordinator.swift Outdated Show resolved Hide resolved
Zotero/Scenes/Detail/DetailCoordinator.swift Show resolved Hide resolved
Zotero/Scenes/Detail/DetailCoordinator.swift Show resolved Hide resolved
@michalrentka michalrentka marked this pull request as draft October 22, 2024 14:19
@michalrentka michalrentka marked this pull request as ready for review October 24, 2024 13:15
@@ -61,6 +61,7 @@ struct StoreCollectionsDbRequest: DbRequest {
collection.trash = response.data.isTrash
collection.trashDate = collection.trash ? Date.now : nil
}
collection.updateSortName()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to check for collection.name != response.data.name and only then update sort name, similar to EditCollectionDbRequest? May need to do so only for existing collections.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems not used anymore, it can be removed.

}
}

func compare<Val>(lValue: Val?, rValue: Val?, nonNilCompare: (Val, Val) -> ComparisonResult) -> ComparisonResult {
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be more clear to use the already available constants for nil alternatives. E.g. for Int, since we want to put nil values in the end of an ascending order, we may use instead:

func compare(lValue: Int?, rValue: Int?) -> ComparisonResult {
    let safeLValue = lValue ?? .max
    let safeRValue = rValue ?? .max
    if safeLValue == safeRValue {
        return .orderedSame
    }
    return safeLValue < safeRValue ? .orderedAscending : .orderedDescending
}

Similarly for Date we can use .distantFuture.

If these comparisons are to be reused throughout the app, we may even consider extending their types accodingly.

}
}
}
if let collections, collectionsIdx < collections.count {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be simplified to:

Suggested change
if let collections, collectionsIdx < collections.count {
if let collections {

collectionsIdx += 1
}
}
if let items, itemsIdx < items.count {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here:

Suggested change
if let items, itemsIdx < items.count {
if let items {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants