-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix up cold email blocker for outlook #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,10 @@ export const threadsQuery = z.object({ | |
| fromEmail: z.string().nullish(), | ||
| limit: z.coerce.number().max(100).nullish(), | ||
| type: z.string().nullish(), | ||
| q: z.string().nullish(), | ||
| nextPageToken: z.string().nullish(), | ||
| labelId: z.string().nullish(), // For Google | ||
| after: z.coerce.date().nullish(), | ||
| before: z.coerce.date().nullish(), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty string (?before=) will fail date coercion; preprocess '' to undefined to skip the filter. Prompt for AI agents |
||
| isUnread: z.coerce.boolean().nullish(), | ||
| }); | ||
| export type ThreadsQuery = z.infer<typeof threadsQuery>; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import useSWR from "swr"; | ||
| import type { ThreadsResponse } from "@/app/api/threads/route"; | ||
| import type { Thread as EmailThread } from "@/components/email-list/types"; | ||
| import type { ThreadsQuery } from "@/app/api/threads/validation"; | ||
|
|
||
| export type Thread = EmailThread; | ||
|
|
||
|
|
@@ -15,11 +16,14 @@ export function useThreads({ | |
| limit?: number; | ||
| refreshInterval?: number; | ||
| }) { | ||
| const searchParams = new URLSearchParams(); | ||
| if (fromEmail) searchParams.set("fromEmail", fromEmail); | ||
| if (limit) searchParams.set("limit", limit.toString()); | ||
| if (type) searchParams.set("type", type); | ||
| const url = `/api/threads?${searchParams.toString()}`; | ||
| const query: ThreadsQuery = { | ||
| fromEmail, | ||
| limit, | ||
| type, | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: params | ||
| const url = `/api/threads?${new URLSearchParams(query as any).toString()}`; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing query as any to URLSearchParams will include keys with undefined values (e.g., limit=undefined, type=undefined), altering intended nullish handling and weakening type safety. Filter out nullish keys and stringify values before building the query string. Prompt for AI agents |
||
| const { data, isLoading, error, mutate } = useSWR<ThreadsResponse>(url, { | ||
| refreshInterval, | ||
| }); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty string (?after=) causes Invalid Date and a 400; preprocess '' to undefined so the filter is ignored instead of failing.
Prompt for AI agents