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

Fix row index #86

Merged
merged 1 commit into from
Sep 26, 2022
Merged

Fix row index #86

merged 1 commit into from
Sep 26, 2022

Conversation

felipecruz91
Copy link
Collaborator

@benja-M-1 reported the following issue:

I import a volume from a fake repo: aaa/aaa:aaa
I delete the created volume
I clone a volume
-> the cloned volume name changes, I have two volumes with the same name that include the -cloned suffix

Screen.Recording.2022-09-23.at.17.23.28.mov

The row index was not being calculated correctly, causing two rows to share the same "unique" id:

image

@github-actions
Copy link

Docker image tag(s) pushed:

docker/volumes-backup-extension:pr-86

Labels added to images:

org.opencontainers.image.title=volumes-backup-extension
org.opencontainers.image.description=Back up, clone, restore, and share Docker volumes effortlessly.
org.opencontainers.image.url=https://github.com/docker/volumes-backup-extension
org.opencontainers.image.source=https://github.com/docker/volumes-backup-extension
org.opencontainers.image.version=pr-86
org.opencontainers.image.created=2022-09-23T15:50:08.205Z
org.opencontainers.image.revision=648ce0c84f63b9e483c9b12da39d76cbee2b859d
org.opencontainers.image.licenses=Apache-2.0

@@ -404,8 +404,10 @@ export function App() {
) => {
if (actionSuccessfullyCompleted) {
const rowsCopy = rows.slice();
const highestId = rows.slice(-1)[0].id;
Copy link
Member

Choose a reason for hiding this comment

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

isn't it similar to

Suggested change
const highestId = rows.slice(-1)[0].id;
const highestId = rows.pop()?.id;

I have added a ? because if rows is empty I think pop returns undefined

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wouldn't pop() eliminate the row from the array? I just want to get the highest id from the rows and don't eliminate any items from the array.

Copy link
Member

Choose a reason for hiding this comment

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

Oh yes, you are right!
Initially I was looking for an alternative to the [0] to avoid any potential error. But accessing an index that does not exist returns undefined. so I guess what could be missing here is only the ?

@felipecruz91 felipecruz91 merged commit 7bb79fe into main Sep 26, 2022
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.

None yet

2 participants