fix: prevent duplicate DMs at creation time, clean up corrupted read states
Replace the unreliable client-side DM dedup loop in populateFromReady with a creation-time guard (findExistingDmForUser) that checks all instances before opening a new DM. Guards added to FriendsPage, NewDmModal, and UserProfilePopout. Also fixes: corrupted read_states from temp_ optimistic message IDs (server migration + client-side validation), federation-aware closeDm/addDmMember API routing, isSelf-based DM member filtering in sidebar/header, and WS event error isolation.
This commit is contained in:
@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom';
|
||||
import { useSocialStore, type TaggedFriend, type TaggedFriendRequest } from '../../stores/socialStore';
|
||||
import { useServerStore } from '../../stores/serverStore';
|
||||
import { useInstanceStore } from '../../stores/instanceStore';
|
||||
import { useUIStore } from '../../stores/uiStore';
|
||||
import { Avatar } from '../ui/Avatar';
|
||||
import { MemberListToggleButton } from '../layout/MemberListToggleButton';
|
||||
import { LoadingSpinner } from '../ui/LoadingSpinner';
|
||||
@@ -53,6 +54,13 @@ export function FriendsPage() {
|
||||
|
||||
const handleOpenDm = async (friendId: string, instanceOrigin: string) => {
|
||||
try {
|
||||
// Check if a DM already exists with this user (on any instance)
|
||||
const existing = useServerStore.getState().findExistingDmForUser({ id: friendId });
|
||||
if (existing) {
|
||||
useUIStore.getState().setShowDms(true);
|
||||
navigate(`/channels/@me/${existing.dm.id}`);
|
||||
return;
|
||||
}
|
||||
let client = api;
|
||||
if (instanceOrigin) {
|
||||
const instance = useInstanceStore.getState().instances.find(i => i.origin === instanceOrigin);
|
||||
|
||||
Reference in New Issue
Block a user