-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat(list): disallow selection of archived or pending items #751
Conversation
PocketKit: Coverage: 76.2
Generated by 🚫 Danger Swift against 0dc8c97 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as described @dskuza ! Just a couple of optional comments, other than that
!
if networkStatus == .unsatisfied { | ||
if item.isArchived { | ||
return !(item.item?.hasArticleComponents ?? false) | ||
} else { | ||
return item.isPending | ||
} | ||
} | ||
|
||
return item.isPending | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can simplify the conditions here with something like this, wdyt?
guard networkStatus == .unsatisfied, item.isArchived else {
return item.isPending
}
return !(item.item?.hasArticleComponents ?? false)
|
||
init(item: ItemsListItem) { | ||
init(item: ItemsListItem, isDisabled: Bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like in the existing calls, isDisabled
is predominantly set to false
: maybe we can add a default value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that'd clean up the unit tests a lot, specifically (which is mainly where the additions are).
Automatically reloads the current Saves list when the network status changes
bd43cfc
to
7046e8a
Compare
Disallows the selection of archived items that contain no offline data, or are pending. Additionally, automatically reloads the current Saves list when the network status changes to show the latest state of the items.
References
IN-1308
Implementation Details
Adds a helper function,
isItemDisabled
, that returns true if:This is then used to initialize item presenters appropriately for the required state by adding a
isDisabled
argument. This is because determining whether or not an item is disabled required use of network monitoring, which is outside the scope of aSavedItem
.Additionally, a network monitor is used to determine when to reload the Saves list as to show the most up-to-date status of items. On monitor change, we send an updated snapshot, reloading the item identifiers representing the visible cells (as to not reload the whole list). This will update the item(s) to their correct coloring.
Test Steps
PR Checklist: