Release 202506151318

This commit is contained in:
pluja
2025-06-15 13:18:22 +00:00
parent effb6689d7
commit f3c9b92ddb
20 changed files with 159 additions and 77 deletions

View File

@@ -107,12 +107,8 @@ const ogImageUrl = makeOgImageUrl(ogImage, Astro.url)
<DynamicFavicon />
<!-- Components -->
{
!Astro.url.pathname.startsWith('/admin') && (
<ClientRouter />
) /* Disable to prevent bugs in important admin forms */
}
<ClientRouter />
<LoadingIndicator color="green" />
<TailwindJsPluggin />
{htmx && <HtmxScript />}

View File

@@ -71,12 +71,13 @@ const [dbComments, pendingCommentsCount, activeRatingComment] = await Astro.loca
'Failed to fetch comments',
async () =>
await prisma.comment.findMany(
makeCommentsNestedQuery({
await makeCommentsNestedQuery({
depth: MAX_COMMENT_DEPTH,
user,
showPending: params.showPending,
serviceId: service.id,
sort: params.sort,
highlightedCommentId: params.comment,
})
),
[],

View File

@@ -16,7 +16,6 @@ type Props = HTMLAttributes<'div'> & {
pushSubscriptions: Prisma.PushSubscriptionGetPayload<{
select: {
endpoint: true
userAgent: true
}
}>[]
}

View File

@@ -27,6 +27,12 @@ if (!Astro.locals.user) return
}
eventSource.onmessage = (event) => {
// NOTE: Disable sse: events when user is not logged in
if (!document.body.hasAttribute('data-is-logged-in')) {
stopServerEventsListener()
return
}
try {
const data = JSON.parse(event.data as string)

View File

@@ -4,6 +4,7 @@
<script>
import { registerSW } from 'virtual:pwa-register'
import { unsubscribeFromPushNotifications } from '../lib/client/clientPushNotifications'
const NO_AUTO_RELOAD_ROUTES = ['/account/welcome', '/500', '/404'] as const satisfies `/${string}`[]
@@ -33,7 +34,7 @@
function shouldSkipAutoReload() {
const currentPath = window.location.pathname
const isErrorPage = document.querySelector('[data-is-error-page]') !== null
const isErrorPage = document.body.hasAttribute('data-is-error-page')
return isErrorPage || NO_AUTO_RELOAD_ROUTES.some((route) => currentPath === route)
}
@@ -48,4 +49,11 @@
window.addEventListener('beforeinstallprompt', (event) => {
event.preventDefault()
})
document.addEventListener('astro:page-load', async () => {
if (!document.body.hasAttribute('data-is-logged-in')) {
await unsubscribeFromPushNotifications()
window.__SW_REGISTRATION__?.unregister()
}
})
</script>

View File

@@ -1,10 +1,10 @@
---
import { Icon } from 'astro-icon/components'
import { differenceInDays } from 'date-fns'
import { verificationStatusesByValue } from '../constants/verificationStatus'
import { verificationStepStatusesByValue } from '../constants/verificationStepStatus'
import { cn } from '../lib/cn'
import { formatDaysAgo } from '../lib/timeAgo'
import type { Prisma } from '@prisma/client'
@@ -27,15 +27,6 @@ type Props = {
}
const { service } = Astro.props
function formatApprovedAt(approvedAt: Date | null) {
if (!approvedAt) return 'less than 15 days ago'
const days = differenceInDays(new Date(), approvedAt)
if (days === 0) return 'today'
if (days === 1) return 'yesterday'
return `${days.toLocaleString()} days ago`
}
---
{
@@ -73,7 +64,7 @@ function formatApprovedAt(approvedAt: Date | null) {
) : service.isRecentlyApproved ? (
<div class="mb-3 rounded-md bg-yellow-900/50 p-2 text-sm text-yellow-400">
This service was approved
{formatApprovedAt(service.approvedAt)}
{service.approvedAt ? formatDaysAgo(service.approvedAt) : 'less than 15 days ago'}
{service.verificationStatus !== 'VERIFICATION_SUCCESS' && ' and it is not verified'}. Proceed with
caution.
<a