fix: DM close visibility flag, wire Remove Friend button, harden deploy script

- Redesign DM close as a visibility flag (closed column) instead of row deletion,
  so message broadcasts still reach users who closed a DM conversation
- Add broadcastDmMessage() helper that auto-resurfaces closed DMs when new messages arrive
- Wire Remove Friend button in DM welcome header with onClick handler and friend check
- Fix deploy.sh to cd to its own directory so rsync always runs from project root
This commit is contained in:
Jannis Braun
2026-02-22 22:29:40 +01:00
parent 6b8fd44a3a
commit 5fe43bc0c8
7 changed files with 112 additions and 108 deletions
@@ -3,6 +3,7 @@ import { Message } from './Message';
import { useChatStore } from '../../stores/chatStore';
import { useServerStore, isDmChannel } from '../../stores/serverStore';
import { useAuthStore } from '../../stores/authStore';
import { useSocialStore } from '../../stores/socialStore';
import { Avatar } from '../ui/Avatar';
import { LoadingSpinner } from '../ui/LoadingSpinner';
import type { MessageWithUser } from '@opencord/shared';
@@ -158,6 +159,8 @@ export function MessageList({ channelId }: MessageListProps) {
function WelcomeHeader({ channelId }: { channelId: string }) {
const dmChannels = useServerStore((s) => s.dmChannels);
const authUser = useAuthStore((s) => s.user);
const removeFriend = useSocialStore((s) => s.removeFriend);
const friends = useSocialStore((s) => s.friends);
const isDm = isDmChannel(channelId);
if (isDm) {
@@ -165,6 +168,7 @@ function WelcomeHeader({ channelId }: { channelId: string }) {
const otherUser = dm?.members.find(m => m.id !== authUser?.id);
const displayName = otherUser?.displayName ?? otherUser?.username ?? 'Unknown';
const username = otherUser?.username ?? 'unknown';
const isFriend = otherUser ? friends.some(f => f.id === otherUser.id) : false;
return (
<div className="px-4 pt-8 pb-4">
@@ -175,11 +179,16 @@ function WelcomeHeader({ channelId }: { channelId: string }) {
<p className="text-discord-text-secondary text-[14px] mt-1">
This is the beginning of your direct message history with <strong>@{username}</strong>.
</p>
<div className="mt-4">
<button className="px-4 py-1.5 bg-discord-bg-accent hover:bg-discord-bg-surface-higher text-[14px] font-medium text-discord-text-primary rounded-[3px] transition-colors">
Remove Friend
</button>
</div>
{isFriend && otherUser && (
<div className="mt-4">
<button
onClick={() => removeFriend(otherUser.id)}
className="px-4 py-1.5 bg-discord-bg-accent hover:bg-discord-bg-surface-higher text-[14px] font-medium text-discord-text-primary rounded-[3px] transition-colors"
>
Remove Friend
</button>
</div>
)}
<div className="mt-6 border-b border-discord-modifier-accent" />
</div>
);