Skip to content

[TAS-5315] ✨ Add LikeRank display and remove staking stats from book cards#889

Open
williamchong wants to merge 1 commit intolikecoin:developfrom
williamchong:feature/staking
Open

[TAS-5315] ✨ Add LikeRank display and remove staking stats from book cards#889
williamchong wants to merge 1 commit intolikecoin:developfrom
williamchong:feature/staking

Conversation

@williamchong
Copy link
Copy Markdown
Member

@williamchong williamchong commented Mar 27, 2026

Replace 應援指數/應援人數 in store view and 我的質押/收益 in shelf view with LikeRank (#n) derived from staking position. Rank is shown on store book cards, CMS tag items, and product detail staking section.

image

Related: likecoin/likecoin-op#309

@williamchong williamchong requested review from a team, Copilot and nwingt March 27, 2026 18:18
@notion-workspace
Copy link
Copy Markdown

LikeRank 2.0

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the book card UI to show a LikeRank (#n) derived from staking position, replacing the previous staking stats in store and shelf contexts, and wires in indexer support for retrieving/storing the rank.

Changes:

  • Add likeRank to bookstore item models and compute/display it on store book cards and CMS tag listings.
  • Add stakingRank support in the staking store + composable, and display it on the product detail staking section.
  • Remove shelf card staking stats props/UI (staked amount / pending rewards).

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
types/bookstore.d.ts Adds likeRank to the BookstoreItem type.
stores/staking.ts Stores and exposes stakingRank per NFT class from the collective indexer.
stores/bookstore.ts Computes likeRank for staking book lists.
shared/utils/collective-indexer.ts Extends CollectiveBookNFT with optional staking_rank.
pages/store/index.vue Passes likeRank into <BookstoreItem> and propagates rank into CMS-tag-derived items.
pages/store/[nftClassId]/index.vue Displays LikeRank in the staking section UI.
pages/shelf/[[walletAddress]].vue Removes passing staking stats props into <BookshelfItem>.
i18n/locales/zh-Hant.json Adds staking_like_rank translation key.
i18n/locales/en.json Adds staking_like_rank translation key.
composables/use-nft-class-staking-data.ts Exposes stakingRank from the staking store.
components/BookstoreItem.vue Replaces staking stats rows with a LikeRank row.
components/BookshelfItem.vue Removes staking visuals/stats on shelf cards.

totalStaked: BigInt(bookNFT.staked_amount || 0),
stakerCount: bookNFT.number_of_stakers,
lastStakedAt: bookNFT.last_staked_at,
likeRank: currentOffset + index + 1,
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

likeRank is derived from stakingBooksMap.value[sortBy].offset via Number(...), but this offset is used as the Collective API pagination.key (cursor), not a guaranteed numeric item offset. This can produce incorrect ranks (especially after loading the next page), and filtering out zero-stake items can also shift the computed index. Prefer using the API-provided staking_rank (now available on CollectiveBookNFT) or compute rank from the existing accumulated item count rather than the pagination cursor.

Copilot uses AI. Check for mistakes.
Comment on lines 128 to 133
:class="getGridItemClassesByIndex(index)"
:nft-class-id="item.nftClassId"
:nft-ids="item.nftIds"
:staked-amount="item.stakedAmount"
:pending-rewards="item.pendingRewards"
:is-owned="item.isOwned"
:progress="item.progress"
:lazy="index >= columnMax"
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

After removing the :pending-rewards prop from <BookshelfItem>, this page still computes pendingRewards in BookshelfItemWithStaking (including formatUnits(...)) but no longer uses it anywhere (only stakedAmount is used for sorting). Consider removing the pendingRewards field and its associated conversions to avoid unnecessary work and reduce data shape complexity.

Copilot uses AI. Check for mistakes.
Comment on lines 128 to 133
:class="getGridItemClassesByIndex(index)"
:nft-class-id="item.nftClassId"
:nft-ids="item.nftIds"
:staked-amount="item.stakedAmount"
:pending-rewards="item.pendingRewards"
:is-owned="item.isOwned"
:progress="item.progress"
:lazy="index >= columnMax"
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

PR description says shelf cards should replace "我的質押/收益" with LikeRank, but the shelf item rendering here only removes :staked-amount / :pending-rewards without adding any LikeRank display. Either update the PR description to match the actual scope, or add the LikeRank UI/data plumbing for shelf items.

Copilot uses AI. Check for mistakes.
Replace 應援指數/應援人數 in store view and 我的質押/收益 in shelf view
with LikeRank (#n) derived from staking position. Rank is shown on
store book cards, CMS tag items, and product detail staking section.
@williamchong williamchong marked this pull request as ready for review March 30, 2026 12:28
@nwingt nwingt requested a review from Copilot March 30, 2026 13:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Comment on lines 392 to 396
totalStaked: BigInt(bookNFT.staked_amount || 0),
stakerCount: bookNFT.number_of_stakers,
lastStakedAt: bookNFT.last_staked_at,
likeRank: currentOffset + index + 1,
}))
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

likeRank is currently computed as currentOffset + index + 1, but stakingBooksMap.value[sortBy].offset is the Collective indexer pagination.key cursor (stored as string), not a numeric offset. Converting it with Number(...) will often yield NaN or an unrelated value, producing incorrect ranks. Since the API type now exposes staking_rank, use bookNFT.staking_rank (with a sensible fallback) instead of deriving rank from the pagination cursor.

Copilot uses AI. Check for mistakes.
Comment on lines +279 to +283
<UCard
v-if="stakingRank > 0"
:ui="{ body: 'p-4' }"
>
<div class="text-center">
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This adds a 4th stats card when stakingRank > 0, but the surrounding grid is still tablet:grid-cols-3. When hasLoggedIn is also true this section will render 4 cards, causing an awkward wrap/misalignment at tablet+ breakpoints. Consider updating the grid columns/responsive layout so the card count is handled consistently.

Copilot uses AI. Check for mistakes.
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.

2 participants