fix url UX exposing state

This commit is contained in:
keyan 2023-10-26 14:36:20 -05:00
parent 43a54d407e
commit 7589295e8c
2 changed files with 7 additions and 4 deletions

View File

@ -68,12 +68,15 @@ export default function Comments ({ parentId, pinned, bio, parentCreatedAt, comm
? <CommentsHeader ? <CommentsHeader
commentSats={commentSats} parentCreatedAt={parentCreatedAt} commentSats={commentSats} parentCreatedAt={parentCreatedAt}
pinned={pinned} bio={bio} handleSort={sort => { pinned={pinned} bio={bio} handleSort={sort => {
const query = router.query const { commentsViewedAt, commentId, ...query } = router.query
delete query.nodata delete query.nodata
router.push({ router.push({
pathname: router.pathname, pathname: router.pathname,
query: { ...router.query, sort } query: { ...query, commentsViewedAt, sort }
}, undefined, { scroll: false }) }, {
pathname: `/items/${parentId}`,
query: sort === defaultCommentSort(pinned, bio, parentCreatedAt) ? undefined : { sort }
}, { scroll: false })
}} }}
/> />
: null} : null}

View File

@ -59,7 +59,7 @@ export default function Item ({ item, rank, belowTitle, right, full, children, s
e.preventDefault() e.preventDefault()
if (e.ctrlKey || e.metaKey) { if (e.ctrlKey || e.metaKey) {
window.open( window.open(
`/items/${item.id}?commentsViewedAt=${viewedAt}`, `/items/${item.id}`,
'_blank', '_blank',
'noopener,noreferrer' 'noopener,noreferrer'
) )