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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pin comment #932

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

Conversation

rayepeng
Copy link

@rayepeng rayepeng commented Aug 20, 2023

WHAT

馃 Generated by Copilot at 369327d

Added the ability to pin and unpin comments on pages. This feature allows users to highlight important or relevant comments and sort them by priority. Modified the Comment, CommentItem, and page components and models, and added Chinese translations for the pin-related UI.

馃 Generated by Copilot at 369327d

Oh we are the coders of the Comment component
We pin and unpin the messages as we please
We use the hooks and the props and the translations
And we sort them by the time and the pinned status

WHY

I want to pin some comments

HOW

馃 Generated by Copilot at 369327d

  • Import and use useUpdateComment hook to enable pinning comments (link, link, link, link, link)
  • Sort comments by pinned status and updated time and render them with VirtualList (link, link)
  • Add pinned state and prop to CommentItem component and conditionally render pin button (link, link)
  • Add pinned parameter to updateComment function in page model and update comment metadata on blockchain (link, link)
  • Add translations for pin-related words and phrases to Chinese locale file (link, link)

CLAIM REWARDS

xlog: https://raye.xlog.app/

discord: rayepeng
For first-time contributors, please leave your xLog address and Discord ID below to claim your rewards.

@vercel
Copy link

vercel bot commented Aug 20, 2023

Someone is attempting to deploy a commit to the RSS3 Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Member

@DIYgod DIYgod left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution. I have some suggestions here.

if (aIsPinned !== bIsPinned) {
return bIsPinned - aIsPinned
}
const aDate = new Date(a.updatedAt)
Copy link
Member

Choose a reason for hiding this comment

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

should use createdAt

const { t } = useTranslation("common")

const data = comments.data?.pages.filter(
(page) => (page?.list?.length ?? 0) > 0,
)
const sortedData = data?.map((item) => {
Copy link
Member

Choose a reason for hiding this comment

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

The logic should be placed within pageModel.getComments, and the pinned comment should be requested separately to ensure that it is always returned. You can refer to pinnedNote in getPagesBySite.

@@ -829,6 +831,7 @@ export async function updateComment(
content,
tags: ["comment"],
sources: ["xlog"],
pinned,
Copy link
Member

Choose a reason for hiding this comment

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

You cannot use pinned here because it does not comply with the Note Metadata specs. Instead, you can place it in the attributes field.

@rayepeng
Copy link
Author

rayepeng commented Aug 22, 2023

Thank you for your contribution. I have a few suggestions to offer.

Thank you, I will make some modifications

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