-
Notifications
You must be signed in to change notification settings - Fork 370
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
add delete button to image previwer in gallery #7170
Conversation
@@ -340,6 +342,31 @@ const Main = ({ isLoadingMore, metadata, onDelete, onLoadMore }) => { | |||
} | |||
}, [handleImageSelection, updateSelectedImage]); | |||
|
|||
const deleteImage = useCallback((name) => { | |||
const image = selectedImages.find(image => image.name === name); |
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.
image 重名时,这里对image 的定位不准确,因此会删除错误
4460949
to
0f02e9f
Compare
@@ -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; |
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.
不是所有的image都会有这个id,这里应该返回一个image, 由调用这个组件库的父组件去处理,或者父组件不通过这个组件也可以知道当前 image (selectedImages[selectedImageIndex]), 可以参考PR https://github.com/haiwen/seahub/pull/6670/files#diff-814435c30c57e3cb88610310c6bbc38456c6618a7802987de27926dc07c18e15R297 自己写的这部分代码。
0f02e9f
to
6d51a79
Compare
setIsImagePopupOpen(false); | ||
setImageIndex(0); | ||
} else { | ||
const newIndex = Math.min(index, newImageItems.length - 1); |
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.
对于删除最后一张,这里有点问题:删除的是最后一张,需要转到第一张(和其他地方的交互保持一致),而不是上一张吧。
da088eb
to
c6313a7
Compare
No description provided.