|
9 | 9 | SortType, |
10 | 10 | } from "lemmy-js-client"; |
11 | 11 | import { revalidatePath } from "next/cache"; |
| 12 | +import { getFormBoolean } from "@/app/(utils)/getFormBoolean"; |
12 | 13 |
|
13 | 14 | export type UnreadCounts = { |
14 | 15 | inbox: GetUnreadCountResponse; |
@@ -47,20 +48,18 @@ export const updateSettingsAction = async (formData: FormData) => { |
47 | 48 | | ListingType |
48 | 49 | | undefined, |
49 | 50 | default_sort_type: formData.get("sort")?.toString() as SortType | undefined, |
50 | | - show_nsfw: getFormBoolean(formData.get("nsfw_show")), |
51 | | - blur_nsfw: getFormBoolean(formData.get("nsfw_blur")), |
52 | | - auto_expand: getFormBoolean(formData.get("auto_expand")), |
53 | | - show_scores: getFormBoolean(formData.get("show_scores")), |
54 | | - bot_account: getFormBoolean(formData.get("is_bot")), |
55 | | - show_bot_accounts: getFormBoolean(formData.get("show_bots")), |
56 | | - show_read_posts: getFormBoolean(formData.get("show_read_posts")), |
| 51 | + show_nsfw: getFormBoolean(formData, "nsfw_show"), |
| 52 | + blur_nsfw: getFormBoolean(formData, "nsfw_blur"), |
| 53 | + auto_expand: getFormBoolean(formData, "auto_expand"), |
| 54 | + show_scores: getFormBoolean(formData, "show_scores"), |
| 55 | + bot_account: getFormBoolean(formData, "is_bot"), |
| 56 | + show_bot_accounts: getFormBoolean(formData, "show_bots"), |
| 57 | + show_read_posts: getFormBoolean(formData, "show_read_posts"), |
57 | 58 | send_notifications_to_email: getFormBoolean( |
58 | | - formData.get("notification_emails"), |
| 59 | + formData, |
| 60 | + "notification_emails", |
59 | 61 | ), |
60 | 62 | }); |
61 | 63 | revalidatePath("/settings"); |
62 | 64 | revalidatePath("/"); |
63 | 65 | }; |
64 | | - |
65 | | -const getFormBoolean = (value: FormDataEntryValue | null): boolean => |
66 | | - value?.toString() === "on"; |
0 commit comments