diff --git a/src/pages/BulkGroupPrivacy.svelte b/src/pages/BulkGroupPrivacy.svelte index e0ce1728..11c60479 100644 --- a/src/pages/BulkGroupPrivacy.svelte +++ b/src/pages/BulkGroupPrivacy.svelte @@ -13,16 +13,16 @@ let success = false; // kinda hacked together from typescript's Required type - const privacy: GroupPrivacy = { - name_privacy: "public", - description_privacy: "public", - icon_privacy: "public", - list_privacy: "public", - metadata_privacy: "public", - visibility: "public", + const privacy: { [P in keyof GroupPrivacy]-?: string; } = { + description_privacy: "no change", + name_privacy: "no change", + list_privacy: "no change", + icon_privacy: "no change", + visibility: "no change", + metadata_privacy: "no change", }; - const privacyNames: GroupPrivacy = { + const privacyNames: { [P in keyof GroupPrivacy]-?: string; } = { name_privacy: "Name", description_privacy: "Description", icon_privacy: "Icon", @@ -31,12 +31,11 @@ visibility: "Visbility", }; - let setPrivate = true; - async function submit() { success = false; loading = true; - const data = privacy; + const dataArray = Object.entries(privacy).filter(([, value]) => value === "no change" ? false : true); + const data = Object.fromEntries(dataArray); try { await api().private.bulk_privacy.group.post({ data }); success = true; @@ -69,10 +68,11 @@ {err} {/if} {#if success} - Member privacy updated! + Group privacy updated! {/if} changeAll(e)}> + @@ -82,8 +82,9 @@ - - + + + {/each} diff --git a/src/pages/BulkMemberPrivacy.svelte b/src/pages/BulkMemberPrivacy.svelte index d9aeaa1d..d962d339 100644 --- a/src/pages/BulkMemberPrivacy.svelte +++ b/src/pages/BulkMemberPrivacy.svelte @@ -13,17 +13,17 @@ import Member from './Member.svelte'; let err = ""; let success = false; - const privacy: MemberPrivacy = { - description_privacy: "public", - name_privacy: "public", - avatar_privacy: "public", - birthday_privacy: "public", - pronoun_privacy: "public", - visibility: "public", - metadata_privacy: "public", + const privacy: { [P in keyof MemberPrivacy]-?: string; } = { + description_privacy: "no change", + name_privacy: "no change", + avatar_privacy: "no change", + birthday_privacy: "no change", + pronoun_privacy: "no change", + visibility: "no change", + metadata_privacy: "no change", }; - const privacyNames: MemberPrivacy = { + const privacyNames: { [P in keyof MemberPrivacy]-?: string; } = { avatar_privacy: "Avatar", birthday_privacy: "Birthday", description_privacy: "Description", @@ -36,7 +36,8 @@ import Member from './Member.svelte'; async function submit() { success = false; loading = true; - const data = privacy; + const dataArray = Object.entries(privacy).filter(([, value]) => value === "no change" ? false : true); + const data = Object.fromEntries(dataArray); try { await api().private.bulk_privacy.member.post({ data }); success = true; @@ -73,6 +74,7 @@ import Member from './Member.svelte'; {/if} changeAll(e)}> + @@ -82,7 +84,8 @@ import Member from './Member.svelte'; - + +