fix: federation reaction identity + remote server reload race condition

- Include user object in reaction_added WS broadcasts for isSelf() resolution
- Use isSelf() instead of userId comparison for reaction ownership checks
- Load remote server detail after ready event to prevent empty channel list
This commit is contained in:
Jannis Braun
2026-03-04 03:53:07 +01:00
parent dca9c4dc83
commit f7809cf457
3 changed files with 32 additions and 6 deletions
+5 -2
View File
@@ -59,8 +59,11 @@ export function Message({ message, isCompact, isFirstInGroup }: MessageProps) {
const removeReaction = useChatStore((s) => s.removeReaction);
const setReplyTo = useChatStore((s) => s.setReplyTo);
const isOwnReaction = (r: { userId: string; user?: { id: string; username: string; homeInstance?: string | null } | null }) =>
r.user ? isSelf(r.user, currentUser) : r.userId === currentUser?.id;
const toggleReaction = (emoji: string) => {
const hasReacted = message.reactions?.some(r => r.userId === currentUser?.id && r.emoji === emoji);
const hasReacted = message.reactions?.some(r => isOwnReaction(r) && r.emoji === emoji);
if (hasReacted) {
removeReaction(message.id, emoji);
} else {
@@ -71,7 +74,7 @@ export function Message({ message, isCompact, isFirstInGroup }: MessageProps) {
const reactionGroups = (message.reactions || []).reduce((acc, r) => {
const group = acc[r.emoji] || { count: 0, me: false };
group.count++;
if (r.userId === currentUser?.id) {
if (isOwnReaction(r)) {
group.me = true;
}
acc[r.emoji] = group;
+13
View File
@@ -118,6 +118,19 @@ function handleEvent(origin: string, event: ServerEvent): void {
loadServerDetail(currentServerId);
}
// For remote instances: if user was viewing one of these servers, load its details
// (fixes race condition on page reload — route params effect fires before remote WS connects)
if (!isHome) {
const { currentServerId: curServerId, loadServerDetail: loadDetail } = useServerStore.getState();
if (curServerId && event.servers.some((s: any) => s.id === curServerId)) {
loadDetail(curServerId);
const { currentChannelId, loadMessages } = useChatStore.getState();
if (currentChannelId) {
loadMessages(currentChannelId, true);
}
}
}
// Only force-reload the current channel on reconnect; other channels keep their cache
if (isHome) {
const { loadMessages: reloadMessages, currentChannelId, setReadStates } = useChatStore.getState();