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
commentSats={commentSats} parentCreatedAt={parentCreatedAt}
pinned={pinned} bio={bio} handleSort={sort => {
const query = router.query
const { commentsViewedAt, commentId, ...query } = router.query
delete query.nodata
router.push({
pathname: router.pathname,
query: { ...router.query, sort }
}, undefined, { scroll: false })
query: { ...query, commentsViewedAt, sort }
}, {
pathname: `/items/${parentId}`,
query: sort === defaultCommentSort(pinned, bio, parentCreatedAt) ? undefined : { sort }
}, { scroll: false })
}}
/>
: null}

View File

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