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

add delete button to image previwer in gallery #7170

Merged
merged 4 commits into from
Dec 14, 2024

Conversation

Aries-0331
Copy link
Contributor

No description provided.

@@ -340,6 +342,31 @@ const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore }) => {
}
}, [handleImageSelection, updateSelectedImage]);

const deleteImage = useCallback((name) => {
const image = selectedImages.find(image => image.name === name);
Copy link
Contributor

Choose a reason for hiding this comment

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

image 重名时,这里对image 的定位不准确,因此会删除错误

@Aries-0331 Aries-0331 force-pushed the feature/add_delete_button_to_gallery_previewer branch from 4460949 to 0f02e9f Compare December 12, 2024 02:09
@@ -30,6 +30,7 @@ class ImageDialog extends React.Component {
const imageItemsLength = imageItems.length;
if (imageItemsLength === 0) return null;
const name = imageItems[imageIndex].name;
const id = imageItems[imageIndex].id;
Copy link
Contributor

Choose a reason for hiding this comment

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

不是所有的image都会有这个id,这里应该返回一个image, 由调用这个组件库的父组件去处理,或者父组件不通过这个组件也可以知道当前 image (selectedImages[selectedImageIndex]), 可以参考PR https://github.com/haiwen/seahub/pull/6670/files#diff-814435c30c57e3cb88610310c6bbc38456c6618a7802987de27926dc07c18e15R297 自己写的这部分代码。

@Aries-0331 Aries-0331 force-pushed the feature/add_delete_button_to_gallery_previewer branch from 0f02e9f to 6d51a79 Compare December 12, 2024 07:46
setIsImagePopupOpen(false);
setImageIndex(0);
} else {
const newIndex = Math.min(index, newImageItems.length - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

对于删除最后一张,这里有点问题:删除的是最后一张,需要转到第一张(和其他地方的交互保持一致),而不是上一张吧。

@Aries-0331 Aries-0331 force-pushed the feature/add_delete_button_to_gallery_previewer branch from da088eb to c6313a7 Compare December 13, 2024 08:23
@freeplant freeplant merged commit cbc8427 into master Dec 14, 2024
1 check passed
@freeplant freeplant deleted the feature/add_delete_button_to_gallery_previewer branch December 14, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants