chore:linting,formatting,type fixing, ....

This commit is contained in:
2025-11-08 14:39:33 +01:00
parent 0754d62d0e
commit ae339d68e1
17 changed files with 86 additions and 74 deletions

View File

@@ -76,7 +76,7 @@ export const POST: RequestHandler = async ({ params, locals, request }) => {
const commentId = crypto.randomUUID();
const now = new Date();
const [newComment] = await db
await db
.insert(findComment)
.values({
id: commentId,
@@ -112,11 +112,14 @@ export const POST: RequestHandler = async ({ params, locals, request }) => {
// Send notification to find owner if not self-comment
const findData = await db.select().from(find).where(eq(find.id, findId)).limit(1);
if (findData.length > 0 && findData[0].userId !== session.userId) {
const findOwner = findData[0];
const shouldNotify = await notificationService.shouldNotify(findOwner.userId, 'find_commented');
const shouldNotify = await notificationService.shouldNotify(
findOwner.userId,
'find_commented'
);
if (shouldNotify) {
// Get commenter's username
const commenterUser = await db
@@ -124,7 +127,7 @@ export const POST: RequestHandler = async ({ params, locals, request }) => {
.from(user)
.where(eq(user.id, session.userId))
.limit(1);
const commenterUsername = commenterUser[0]?.username || 'Someone';
const findTitle = findOwner.title || 'your find';

View File

@@ -65,7 +65,7 @@ export async function POST({
const findOwner = existingFind[0];
if (findOwner.userId !== locals.user.id) {
const shouldNotify = await notificationService.shouldNotify(findOwner.userId, 'find_liked');
if (shouldNotify) {
// Get liker's username
const likerUser = await db
@@ -73,7 +73,7 @@ export async function POST({
.from(user)
.where(eq(user.id, locals.user.id))
.limit(1);
const likerUsername = likerUser[0]?.username || 'Someone';
const findTitle = findOwner.title || 'your find';

View File

@@ -1,7 +1,7 @@
import { json } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import { findComment, user } from '$lib/server/db/schema';
import { eq, and } from 'drizzle-orm';
import { findComment } from '$lib/server/db/schema';
import { eq } from 'drizzle-orm';
import type { RequestHandler } from './$types';
export const DELETE: RequestHandler = async ({ params, locals }) => {

View File

@@ -78,7 +78,7 @@ export const PUT: RequestHandler = async ({ params, request, locals }) => {
if (action === 'accept') {
const senderId = friendshipRecord.userId;
const shouldNotify = await notificationService.shouldNotify(senderId, 'friend_accepted');
if (shouldNotify) {
// Get accepter's username
const accepterUser = await db
@@ -86,7 +86,7 @@ export const PUT: RequestHandler = async ({ params, request, locals }) => {
.from(user)
.where(eq(user.id, locals.user.id))
.limit(1);
const accepterUsername = accepterUser[0]?.username || 'Someone';
await notificationService.createNotification({

View File

@@ -41,7 +41,10 @@ export const PATCH: RequestHandler = async ({ locals, request }) => {
} else if (Array.isArray(notificationIds) && notificationIds.length > 0) {
await notificationService.markAsRead(notificationIds);
} else {
return json({ error: 'Invalid request: provide notificationIds or markAll' }, { status: 400 });
return json(
{ error: 'Invalid request: provide notificationIds or markAll' },
{ status: 400 }
);
}
return json({ success: true });
@@ -66,7 +69,10 @@ export const DELETE: RequestHandler = async ({ locals, request }) => {
} else if (notificationId) {
await notificationService.deleteNotification(notificationId, user.id);
} else {
return json({ error: 'Invalid request: provide notificationId or deleteAll' }, { status: 400 });
return json(
{ error: 'Invalid request: provide notificationId or deleteAll' },
{ status: 400 }
);
}
return json({ success: true });

View File

@@ -134,10 +134,10 @@
// Search users when query changes with debounce
let searchTimeout: ReturnType<typeof setTimeout>;
$effect(() => {
// Track searchQuery dependency explicitly
searchQuery;
clearTimeout(searchTimeout);
searchTimeout = setTimeout(searchUsers, 300);
if (searchQuery) {
clearTimeout(searchTimeout);
searchTimeout = setTimeout(searchUsers, 300);
}
});
</script>