https://drive.google.com/file/d/1JKRj2gVf2b_6cKo0tGI1Puy46kb6AAzH/view?usp=sharing&resourcekey=0-kplCicxzlHZrgWpXBcflkgCan we also deselect images in the picker?
if ([self.dataSource
respondsToSelector:@selector(attachedImageAssetIDsForPresenter:)]) {`attachedImageAssetIDsForPresenter` isn't optional, I don't think this check is necessary.
config.selectionLimit = limit + preselectedAssetIDs.count;As mentioned above, we need to update this logic only if we are able to deselect preselected images.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Can we also deselect images in the picker?
- If we can, we should remove composebox items when we deselect a preselected image.
- If we can't, we shouldn't update the selectionLimit as the gallery picker title will be wrong (e.g "select up to 10 images" while we should only select up to 9).
Good catch, I've updated the code to handle deselecting images accordingly.
if ([self.dataSource
respondsToSelector:@selector(attachedImageAssetIDsForPresenter:)]) {`attachedImageAssetIDsForPresenter` isn't optional, I don't think this check is necessary.
Done
config.selectionLimit = limit + preselectedAssetIDs.count;As mentioned above, we need to update this logic only if we are able to deselect preselected images.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
- (void)composeboxPickerPresenter:(ComposeboxPickerPresenter*)presenter
didPickImages:
(NSArray<ComposeboxPickerImageResult*>*)results {Double checking, is this also called when the user taps cancel in the photo picker?
If so would this incorrectly remove items? (e.g Deselect and then tap cancel.)
- (void)removeImageWithAssetID:(NSString*)assetID {```suggestion
[self removeItem:item];I think this would also remove image items taken from Camera.
NSMutableArray<ComposeboxPickerImageResult*>* updatedImageResults =
[[NSMutableArray alloc] init];
if (_preselection.images) {
updatedImageResults = [_preselection.images mutableCopy];
}
[updatedImageResults addObjectsFromArray:imageItems];
What about the images taken from a Camera. (not the gallery)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
- (void)composeboxPickerPresenter:(ComposeboxPickerPresenter*)presenter
didPickImages:
(NSArray<ComposeboxPickerImageResult*>*)results {Double checking, is this also called when the user taps cancel in the photo picker?
If so would this incorrectly remove items? (e.g Deselect and then tap cancel.)
It is not called the behavior here is correct.
- (void)removeImageWithAssetID:(NSString*)assetID {Elmehdi Rahmaoui```suggestion
- (void)removeItemWithAssetID:(NSString*)assetID {
- ```
The goal of the function is to remove images not any item as per the check `if (item.type == ComposeboxInputItemType::kComposeboxInputItemTypeImage &&
[item.assetID isEqualToString:assetID]) `
I think this would also remove image items taken from Camera.
Good catch, the code is now updated, and the behavior is correct.
NSMutableArray<ComposeboxPickerImageResult*>* updatedImageResults =
[[NSMutableArray alloc] init];
if (_preselection.images) {
updatedImageResults = [_preselection.images mutableCopy];
}
[updatedImageResults addObjectsFromArray:imageItems];
What about the images taken from a Camera. (not the gallery)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
BOOL isCamera =Please add a comment explaining logic here.
if (imageResult.assetID.length == 0) {I'm not sure what this checks, does it check if this is an image from the camera? If so is there a better way to check for this?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Please add a comment explaining logic here.
Done
I'm not sure what this checks, does it check if this is an image from the camera? If so is there a better way to check for this?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
6 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: ios/chrome/browser/composebox/coordinator/composebox_input_plate_coordinator.mm
Insertions: 5, Deletions: 0.
@@ -769,6 +769,11 @@
- (void)composeboxPickerPresenter:(ComposeboxPickerPresenter*)presenter
didPickImages:
(NSArray<ComposeboxPickerImageResult*>*)results {
+ // Gallery picker results (PHPickerViewController) return the complete set of
+ // selected gallery items. Reconcile preselected asset IDs so that any gallery
+ // photo deselected by the user is removed from attachments. Camera picker
+ // captures lack asset IDs and represent single new photos, so skip gallery
+ // reconciliation.
BOOL isCamera =
results.firstObject.source == ComposeboxInputItemSource::kCameraPicker;
NSArray<NSString*>* attachedAssetIDs = [_mediator attachedImageAssetIDs];
```
```
The name of the file: ios/chrome/browser/composebox/menu/coordinator/composebox_menu_mediator.mm
Insertions: 1, Deletions: 1.
@@ -78,7 +78,7 @@
// Gallery picker results. Retain existing non-gallery images from
// preselection, and replace gallery images with `imageItems`.
for (ComposeboxPickerImageResult* imageResult in _preselection.images) {
- if (imageResult.assetID.length == 0) {
+ if (imageResult.source != ComposeboxInputItemSource::kGalleryPicker) {
[updatedImages addObject:imageResult];
}
}
```
[ios][composebox] Pre-select attached images in gallery picker
Pass preselected image asset identifiers to `PHPickerConfiguration` when
launching the gallery picker from the Composebox input plate and menu.
This ensures that previously attached photos display checkmarks when the
user reopens the system photo picker.
Demo
https://drive.google.com/file/d/1qgh7AkZdGTNFD0lSc8PTfZywBR1960PE/view?usp=sharing&resourcekey=0-rLXzxbFBiaXM4MiYLjxYvQ
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |