BioDrop icon indicating copy to clipboard operation
BioDrop copied to clipboard

[FIX] fixes the links view count not being sorted

Open Aadarsh805 opened this issue 3 years ago • 5 comments

Fixes Issue

closes #3434

Changes proposed

This was happening due to not having the correct key property while mapping over the link

Instead of using index as key, changed it to link.name the Link has name, icon and url values in it, the name seemed the most optimal

Check List (Check all the applicable boxes)

  • [x ] My code follows the code style of this project.
  • [ ] My change requires changes to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ x] All new and existing tests passed.
  • [ x] This PR does not contain plagiarized content.
  • [ x] The title of my pull request is a short description of the requested changes.

Screenshots

Screenshot from 2023-01-15 22-01-45

image

Note to reviewers

If having link.name as the key is not the appropriate option, we can add an id on each link before mapping over it like this

  data.links = data.links.map((link, i) => ({ id: i, ...link }));

By this, each link will also have a unique id field which can be used as a key

Aadarsh805 avatar Jan 15 '23 16:01 Aadarsh805

@ChinmayMhatre can you have a look at this Also tell me if using the name as key is a good practice or not, or I'll switch to the other method to fix the issue as I mentioned above

Aadarsh805 avatar Jan 16 '23 21:01 Aadarsh805

@ChinmayMhatre can you have a look at this Also tell me if using the name as key is a good practice or not, or I'll switch to the other method to fix the issue as I mentioned above

I think using the map's index would be better than using the name.

ChinmayMhatre avatar Jan 17 '23 01:01 ChinmayMhatre

@ChinmayMhatre can you have a look at this Also tell me if using the name as key is a good practice or not, or I'll switch to the other method to fix the issue as I mentioned above

I'll take a look at the code at night.

ChinmayMhatre avatar Jan 17 '23 05:01 ChinmayMhatre

@ChinmayMhatre can you have a look at this Also tell me if using the name as key is a good practice or not, or I'll switch to the other method to fix the issue as I mentioned above

I think using the map's index would be better than using the name.

Using index was the reason it was not working

Aadarsh805 avatar Jan 17 '23 08:01 Aadarsh805

@ChinmayMhatre can you have a look at this Also tell me if using the name as key is a good practice or not, or I'll switch to the other method to fix the issue as I mentioned above

I think using the map's index would be better than using the name.

Using index was the reason it was not working

I meant this

Note to reviewers

If having link.name as the key is not the appropriate option, we can add an id on each link before mapping over it like this

data.links = data.links.map((link, i) => ({ id: i, ...link }));

By this, each link will also have a unique id field which can be used as a key

You could try using this id

ChinmayMhatre avatar Jan 17 '23 08:01 ChinmayMhatre

What about using url that will be unique?

eddiejaoude avatar Jan 20 '23 18:01 eddiejaoude

Reviewpad Report

:information_source: Messages

  • Kudos for your 10th pull request! You are awesome

github-actions[bot] avatar Jan 20 '23 18:01 github-actions[bot]

What about using url that will be unique?

can't say, it's user-defined that's why

Aadarsh805 avatar Jan 20 '23 19:01 Aadarsh805