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

Crosspost replies to nostr #1093

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

AustinKelsay
Copy link
Contributor

@AustinKelsay AustinKelsay commented Apr 19, 2024

Description

Allows for crossposting of replies IF both root and parent have been crossposted already

Screenshots

walkthrough

Additional Context

  • I needed to add a few queries to refetch parent/root items to check noteId in the crossposting flow and also determine if the "crosspost" option should render or not
  • Had to handle the two different kinds of replies (replies to a short text note and replies to a parameterized replaceable note)
  • Had to add noteId to COMMENT_FIELDS

Checklist

  • Are your changes backwards compatible?

  • Did you QA this? Could we deploy this straight to production?

  • For frontend changes: Tested on mobile?

  • Did you introduce any new environment variables? If so, call them out explicitly in the PR description.

Summary by CodeRabbit

  • New Features
    • Enhanced item information to include crossposting capabilities for both top-level items and replies.
    • Added handling for reply events in the crossposting functionality.
  • Bug Fixes
    • Included noteId in comment data fields to ensure complete information retrieval.

Copy link
Contributor

coderabbitai bot commented Apr 19, 2024

Walkthrough

Walkthrough

The updates focus on enhancing the functionality related to crossposting and handling replies in a web application. New functionalities include fetching and displaying parent item details, managing replies through a specialized function, and refining event creation logic. Additionally, a minor update was made to include a new field in comment data structures.

Changes

File Changes Summary
.../item-info.js, .../use-crossposter.js Enhanced crossposting capabilities by adding import statements, state management, and query handling in item-info.js. Introduced reply handling and updated event creation logic in use-crossposter.js.
fragments/comments.js Added noteId to COMMENT_FIELDS for better comment management.

Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between d7ecbba and 82fddf2.
Files selected for processing (3)
  • components/item-info.js (3 hunks)
  • components/use-crossposter.js (5 hunks)
  • fragments/comments.js (1 hunks)
Additional comments not posted (5)
fragments/comments.js (1)

28-28: The addition of noteId to COMMENT_FIELDS is correctly implemented and necessary for tracking crossposted comments.

components/use-crossposter.js (2)

76-115: The implementation of replyToEvent correctly handles the creation of events for replies, including decoding nip19 data. Consider refining the error messages to be more specific to the context in which they occur for better debugging and user feedback.


193-205: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [196-227]

The updates to handleEventCreation to include reply handling are correctly implemented. This change enables the application to handle different types of items appropriately.

components/item-info.js (2)

38-50: The implementation of the useQuery hook to fetch parent item data and the subsequent state update based on the crosspost status are correctly handled. This setup is essential for the conditional rendering of the crosspost option.


178-183: The conditional rendering logic for crossposting top-level items and replies based on their crosspost status is correctly implemented. This ensures that the crosspost option is only available under the correct conditions, aligning with the PR's objectives.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member

@huumn huumn left a comment

Choose a reason for hiding this comment

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

Awesome! I wasn't expecting this one.

I think the hard part of this is going to be getting all the data we need in a performant/consistent way.

const [meTotalSats, setMeTotalSats] = useState(0)
const root = useRoot()
const sub = item?.sub || root?.sub

const { data } = useQuery(ITEM_FULL, { variables: { id: item?.parentId } })
Copy link
Member

Choose a reason for hiding this comment

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

The performance implications of this are significant. For every comment, it queries the server for the entire parent. In a comment thread with 100 comments, this will make 100 requests to the server.

I think what we want to do instead is when rendering a Comment component from a parent item/comment, send it this info as props.

When a comment is in list of comments like on a profile, you'll want to use a different query fragment with a nested resolver for parent so that this data is gathered when all the other data is. An example of this is the nested resolver for root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sweet thanks for the feedback! I'll get right on this

@huumn huumn marked this pull request as draft May 13, 2024 23:08
@huumn huumn marked this pull request as draft May 13, 2024 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants