client: don't re-direct the owner of a file if it's expired

This commit is contained in:
Max Leiter 2022-04-08 23:30:07 -07:00
parent 9fe9b818c4
commit d1415d1ee2
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: A3512F2F2F17EBDA

View file

@ -29,10 +29,10 @@ const PostPage = ({ post }: Props) => {
const [isExpired, setIsExpired] = useState(post.expiresAt ? new Date(post.expiresAt) < new Date() : null)
const [isLoading, setIsLoading] = useState(true)
useEffect(() => {
if (isExpired) {
const isOwner = post.users ? post.users[0].id === Cookies.get("drift-userid") : false
if (!isOwner && isExpired) {
router.push("/expired")
}
const isOwner = post.users ? post.users[0].id === Cookies.get("drift-userid") : false
const expirationDate = new Date(post.expiresAt ? post.expiresAt : "")
if (!isOwner && expirationDate < new Date()) {