generated from t3-oss/create-t3-turbo
-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Use post's replyRef
instead of thread top post to stop stranded replies
#56
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
mozzius
commented
Sep 15, 2023
apps/expo/src/lib/hooks/composer.ts
Outdated
Comment on lines
50
to
85
const getReplyRef = (post: AppBskyFeedDefs.PostView) => { | ||
if (AppBskyFeedPost.isRecord(post.record)) { | ||
return post.record.reply; | ||
} | ||
}; | ||
|
||
export const useComposer = () => { | ||
const router = useRouter(); | ||
const queryClient = useQueryClient(); | ||
return { | ||
open: () => router.push("/composer"), | ||
reply: (reply: { | ||
parent: AppBskyFeedDefs.PostView; | ||
root: AppBskyFeedDefs.PostView; | ||
}) => { | ||
queryClient.setQueryData(["context", reply.parent.uri], { | ||
post: reply.parent, | ||
reply: (post: AppBskyFeedDefs.PostView) => { | ||
queryClient.setQueryData(["context", post.uri], { | ||
post, | ||
} satisfies AppBskyFeedDefs.ThreadViewPost); | ||
|
||
const parent = { | ||
uri: post.uri, | ||
cid: post.cid, | ||
} satisfies ComAtprotoRepoStrongRef.Main; | ||
|
||
const root = getReplyRef(post)?.root ?? parent; | ||
|
||
const replyRef = { | ||
parent, | ||
root, | ||
} satisfies AppBskyFeedPost.ReplyRef; | ||
|
||
router.push( | ||
`/composer?reply=${encodeURIComponent( | ||
JSON.stringify({ | ||
parent: { | ||
uri: reply.parent.uri, | ||
cid: reply.parent.cid, | ||
}, | ||
root: { | ||
uri: reply.root.uri, | ||
cid: reply.root.cid, | ||
}, | ||
} satisfies AppBskyFeedPost.ReplyRef), | ||
)}`, | ||
`/composer?reply=${encodeURIComponent(JSON.stringify(replyRef))}`, | ||
); | ||
}, | ||
quote: (post: AppBskyFeedDefs.PostView) => | ||
router.push( | ||
`/composer?quote=${encodeURIComponent( | ||
JSON.stringify({ | ||
uri: post.uri, | ||
cid: post.cid, | ||
}), | ||
)}`, | ||
), | ||
quote: (ref: ComAtprotoRepoStrongRef.Main) => | ||
router.push(`/composer?quote=${encodeURIComponent(JSON.stringify(ref))}`), | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the relevant part
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Should fix the issue revealed by the more rigourous checks to
replyRef
s added recently