feat(privacy): add private-message permission toggle
This commit is contained in:
@@ -29,6 +29,7 @@ export function ChatList() {
|
||||
const [profileUsername, setProfileUsername] = useState("");
|
||||
const [profileBio, setProfileBio] = useState("");
|
||||
const [profileAvatarUrl, setProfileAvatarUrl] = useState("");
|
||||
const [profileAllowPrivateMessages, setProfileAllowPrivateMessages] = useState(true);
|
||||
const [profileError, setProfileError] = useState<string | null>(null);
|
||||
const [profileSaving, setProfileSaving] = useState(false);
|
||||
const deleteModalChat = chats.find((chat) => chat.id === deleteModalChatId) ?? null;
|
||||
@@ -101,6 +102,7 @@ export function ChatList() {
|
||||
setProfileUsername(me.username || "");
|
||||
setProfileBio(me.bio || "");
|
||||
setProfileAvatarUrl(me.avatar_url || "");
|
||||
setProfileAllowPrivateMessages(me.allow_private_messages ?? true);
|
||||
}, [me]);
|
||||
|
||||
const filteredChats = chats.filter((chat) => {
|
||||
@@ -323,6 +325,14 @@ export function ChatList() {
|
||||
<input className="w-full rounded bg-slate-800 px-3 py-2 text-sm" placeholder="Username" value={profileUsername} onChange={(e) => setProfileUsername(e.target.value.replace("@", ""))} />
|
||||
<input className="w-full rounded bg-slate-800 px-3 py-2 text-sm" placeholder="Bio (optional)" value={profileBio} onChange={(e) => setProfileBio(e.target.value)} />
|
||||
<input className="w-full rounded bg-slate-800 px-3 py-2 text-sm" placeholder="Avatar URL (optional)" value={profileAvatarUrl} onChange={(e) => setProfileAvatarUrl(e.target.value)} />
|
||||
<label className="flex items-center gap-2 rounded bg-slate-800 px-3 py-2 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={profileAllowPrivateMessages}
|
||||
onChange={(e) => setProfileAllowPrivateMessages(e.target.checked)}
|
||||
/>
|
||||
Allow private messages
|
||||
</label>
|
||||
</div>
|
||||
{profileError ? <p className="mt-2 text-xs text-red-400">{profileError}</p> : null}
|
||||
<div className="mt-3 flex gap-2">
|
||||
@@ -337,7 +347,8 @@ export function ChatList() {
|
||||
name: profileName.trim() || undefined,
|
||||
username: profileUsername.trim() || undefined,
|
||||
bio: profileBio.trim() || null,
|
||||
avatar_url: profileAvatarUrl.trim() || null
|
||||
avatar_url: profileAvatarUrl.trim() || null,
|
||||
allow_private_messages: profileAllowPrivateMessages
|
||||
});
|
||||
useAuthStore.setState({ me: updated });
|
||||
await loadChats(search.trim() ? search : undefined);
|
||||
|
||||
Reference in New Issue
Block a user