"use client"; import { ActionButton } from "components/ActionBar/ActionButton"; import { SettingsSmall } from "components/Icons/SettingsSmall"; import { Toggle } from "components/Toggle"; import { Popover } from "components/Popover"; import { useLeafletPublicationData } from "components/PageSWRDataProvider"; import { useReplicache } from "src/replicache"; import { useSubscribe } from "src/replicache/useSubscribe"; type PostPreferences = { showComments?: boolean; showMentions?: boolean; showRecommends?: boolean; }; export function PostSettings() { let { data: pub, normalizedPublication } = useLeafletPublicationData(); let { rep } = useReplicache(); let postPreferences = useSubscribe(rep, (tx) => tx.get("post_preferences"), ); if (!pub || !pub.publications) return null; let pubPrefs = normalizedPublication?.preferences; let showComments = postPreferences?.showComments ?? pubPrefs?.showComments ?? true; let showMentions = postPreferences?.showMentions ?? pubPrefs?.showMentions ?? true; let showRecommends = postPreferences?.showRecommends ?? pubPrefs?.showRecommends ?? true; const updatePreference = ( field: keyof PostPreferences, value: boolean, ) => { let current: PostPreferences = postPreferences || {}; rep?.mutate.updatePublicationDraft({ preferences: { ...current, [field]: value }, }); }; return ( } label="Settings" /> } >
This Post Settings
updatePreference("showComments", !showComments)} >
Show Comments
updatePreference("showMentions", !showMentions)} >
Show Mentions
Display a list of Bluesky mentions about your post
updatePreference("showRecommends", !showRecommends)} >
Show Recommends
Allow readers to recommend/like your post
); }