Skip to content

Commit

Permalink
chore: clean codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hantsy committed Jan 3, 2025
1 parent 3153db7 commit 042c6ba
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions dgs-subscription-ui/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,13 @@ export class AppComponent implements OnInit, OnDestroy {
this.messagesQuery.subscribeToMore({
document: MESSAGE_SUBSCRIPTION_QUERY,
variables: {},
updateQuery: (prev: {messages:[TextMessage]}, options: {
subscriptionData: {
data: {messageSent: TextMessage};
};
}) => {
updateQuery: (prev, { subscriptionData}) => {
console.log('prev: {}', prev);
console.log('subscription data: {}', options.subscriptionData);
if (!options.subscriptionData.data) {
console.log('subscription data: {}', subscriptionData);
if (!subscriptionData.data) {
return prev;
}
const newMsg = options.subscriptionData.data.messageSent;
const newMsg = (subscriptionData.data as {messageSent: TextMessage}).messageSent;
if (prev?.messages) {
return { messages: [...prev.messages, newMsg] };
} else {
Expand Down

0 comments on commit 042c6ba

Please sign in to comment.