Skip to content
This repository has been archived by the owner on May 7, 2023. It is now read-only.

Commit

Permalink
Fix Multiple Device Self Message Issue (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
0916dhkim authored Jun 4, 2021
1 parent 3f460ec commit 508a2a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 11 additions & 1 deletion client/src/relay/updaters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ function prependMessageToChannel(
'Message',
);

ConnectionHandler.insertEdgeBefore(messagesConnection, newMessageEdge);
// Insert new edge if the message is not already in connection.

const existingEdges = messagesConnection?.getLinkedRecords('edges') ?? [];

if (
!existingEdges.find(
(edge) =>
edge.getLinkedRecord('node')?.getDataID() === messageProxy.getDataID(),
)
)
ConnectionHandler.insertEdgeBefore(messagesConnection, newMessageEdge);
}

/**
Expand Down
5 changes: 1 addition & 4 deletions server/src/resolvers/Message/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ export const onMessage = subscriptionField('onMessage', {
},
});

const correctChannel = !!membership; // Message is sent to the auth user's channel.
const fromSelf = payload.senderId === userId; // Message is sent by the auth user.

return correctChannel && !fromSelf;
return !!membership; // Message is sent to the auth user's channel.
},
),
resolve: (payload) => {
Expand Down

0 comments on commit 508a2a4

Please sign in to comment.