Closed zahhar closed 3 years ago
To keep the insertion order in the contract, we cannot use TreeMap
[1] as discussed in our daily stand up. The TreeMap
data structure retrieves its elements sorted by key (Corgi
id), not by insertion order.
[1] https://docs.rs/near-sdk/2.0.1/near_sdk/collections/struct.TreeMap.html
@acuarica - I'd like to suggest the way to solve the 'sorting dilemma' we discussed on the standup.
We could always sort by CreatedDate (abs date qhen Corgi was minted initially) across all endpoints. Difference is that:
Thanks for the suggestion. The main issue with this solution is that it might show the global corgis and user owned corgis in different order. This might be confusing for the user. Let's take this scenario:
(the format G: # | A: # | B: #
represents the corgis displayed Globally, for user A and user B respectively, the leftmost number represents first corgi the user see)
G: 1 | A: 1 | B:
G: 2 1 | A: 1 | B: 2
G: 2 1 | A: | B: 1 2
In step 3, the global list didn’t change, however user B now sees the transferred Corgi 1 in the top of her list. That's why we might be better off having a consistent ordering across the contract. The homepage can be corgis with last activities instead.
The homepage can be corgis with last activities instead.
This looks elegant. In this case we only need to rename the block title on the homepage. Lets go with it.
Tasks
TreeMap
can be used to retrieve corgis by last inserted (it can't, see https://github.com/epam/corgis/issues/128#issuecomment-783308681)