From 042c6ba11203191ec61f5e5e7b14dd642c8b985a Mon Sep 17 00:00:00 2001 From: hantsy Date: Fri, 3 Jan 2025 14:05:26 +0800 Subject: [PATCH] chore: clean codes --- dgs-subscription-ui/src/app/app.component.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/dgs-subscription-ui/src/app/app.component.ts b/dgs-subscription-ui/src/app/app.component.ts index b3c9721cb..043ca137c 100644 --- a/dgs-subscription-ui/src/app/app.component.ts +++ b/dgs-subscription-ui/src/app/app.component.ts @@ -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 {