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

Improve item detail fields #1051

Merged
merged 20 commits into from
Jan 31, 2025
Merged

Conversation

mvasilak
Copy link
Contributor

@mvasilak mvasilak commented Jan 9, 2025

  • Doesn't show empty fields when editing an item of attachment type.
  • Properly ends item details editing if no changes have occured when Done is pressed.
  • Updates date modified for each saved item details change.
  • Fixes issues that reloaded previous collection view values during editing.
  • Delays item field edits processing in the action handler, instead of debouncing the cell text fields observation, so the view model is always up to date, even if the Done is pressed to quickly.

@mvasilak mvasilak requested a review from michalrentka January 9, 2025 13:57
Copy link
Contributor

@michalrentka michalrentka left a comment

Choose a reason for hiding this comment

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

Some comments for ItemDetailState.Data struct:

  • isAttachment in Data should probably a constant? "Normal" item can't become an attachment, so that flag won't ever change.
  • creators and creatorIds can be converted to OrderedDictionary too.
  • maxFieldTitleWidth, maxNonemptyFieldTitleWidth don't see to be used anymore, can they be deleted?
  • should attributedTitle maybe be exluded from equatability of this struct? If for example font size changes (from iOS accessibility settings), the NSAttributedString would differ even if title never changed? It's quite an edge case, but no need to compare attributed string when we already compare the original.

What happens, if the user starts editing, the RItem.changesSyncPaused flag is set to true and then the user crashes at some point while editing? When they open the app, that RItem's sync is still disabled, right? Maybe on app launch/activation we should reset all of these flags to false?

I also noticed a UI bug. When you edit some field and quickly tap "Done", the field change is debounced and since we tap "Done" before the debounce triggers, our UI then shows old state. It's stored in database and synced properly.

@mvasilak
Copy link
Contributor Author

mvasilak commented Jan 20, 2025

@michalrentka

Some comments for ItemDetailState.Data struct:

isAttachment in Data should probably a constant? "Normal" item can't become an attachment, so that flag won't ever change.

Changed in e7309d4

creators and creatorIds can be converted to OrderedDictionary too.

Changed in 0ad0e2d

maxFieldTitleWidth, maxNonemptyFieldTitleWidth don't see to be used anymore, can they be deleted?

Changed in d0bfd3c

should attributedTitle maybe be exluded from equatability of this struct? If for example font size changes (from iOS accessibility settings), the NSAttributedString would differ even if title never changed? It's quite an edge case, but no need to compare attributed string when we already compare the original.

Changed in 5bad313

What happens, if the user starts editing, the RItem.changesSyncPaused flag is set to true and then the user crashes at some point while editing? When they open the app, that RItem's sync is still disabled, right? Maybe on app launch/activation we should reset all of these flags to false?

This would apply only to newly created items, as editing existing items is fully live-updating now. In theory there should be only one such entry, but just to be safe, assuming they could be more, we could offer an alert with choices to the user:

  • Go to the edit screen (available only when there is one such item)
  • Delete all such pending items
  • Save all such pending items

I also noticed a UI bug. When you edit some field and quickly tap "Done", the field change is debounced and since we tap "Done" before the debounce triggers, our UI then shows old state. It's stored in database and synced properly.

This should be fixed in 20126a8

@mvasilak mvasilak requested a review from michalrentka January 20, 2025 10:28
@michalrentka
Copy link
Contributor

What happens, if the user starts editing, the RItem.changesSyncPaused flag is set to true and then the user crashes at some point while editing? When they open the app, that RItem's sync is still disabled, right? Maybe on app launch/activation we should reset all of these flags to false?

This would apply only to newly created items, as editing existing items is fully live-updating now. In theory there should be only one such entry, but just to be safe, assuming they could be more, we could offer an alert with choices to the user:

  • Go to the edit screen (available only when there is one such item)
  • Delete all such pending items
  • Save all such pending items

Right, I didn't notice that changesSyncPaused is only used when creating a new item. In that case EndItemDetailEditingDbRequest could probably be renamed to something like EndItemCreationDbRequest and call it only when we're actually create an item in ItemDetailActionHandler.endEditing.

The whole ItemDetailActionHandler.endEditing can be changed a lot. We don't even need to compare snapshot to data at this point, everything has been stored already. Just always call the thing which is in guard else now and then call EndItemDetailEditingDbRequest for item creation so that syncing is allowed and nothing else is needed. The whole endEditing has leftovers from when we had Cancel + Save buttons, but it's unnecessary now. Am I misunderstanding something?

@mvasilak mvasilak force-pushed the improve-item-detail-fields branch from 5bad313 to 287b66f Compare January 29, 2025 14:02
Fix app delegate migration
@mvasilak
Copy link
Contributor Author

The whole ItemDetailActionHandler.endEditing can be changed a lot. We don't even need to compare snapshot to data at this point, everything has been stored already. Just always call the thing which is in guard else now and then call EndItemDetailEditingDbRequest for item creation so that syncing is allowed and nothing else is needed. The whole endEditing has leftovers from when we had Cancel + Save buttons, but it's unnecessary now. Am I misunderstanding something?

Indeed, check e183a07 & 8e54ace

@mvasilak mvasilak requested a review from michalrentka January 30, 2025 14:50
@mvasilak mvasilak merged commit a04d797 into zotero:master Jan 31, 2025
1 check passed
@mvasilak mvasilak deleted the improve-item-detail-fields branch January 31, 2025 10:07
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