Skip to content

Commit 879d6bb

Browse files
authored
feat(subscriptions): connection state (#6084)
1 parent 71fadaf commit 879d6bb

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/pages/index.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,7 @@ export default function IndexPage() {
171171
},
172172
});
173173

174-
const [currentlyTyping, setCurrentlyTyping] = useState<string[]>([]);
175-
trpc.post.whoIsTyping.useSubscription(undefined, {
176-
onData(data) {
177-
setCurrentlyTyping(data);
178-
},
179-
});
174+
const whoIsTypingResult = trpc.post.whoIsTyping.useSubscription();
180175

181176
return (
182177
<>
@@ -293,8 +288,8 @@ export default function IndexPage() {
293288
<div className="w-full">
294289
<AddMessageForm onMessagePost={() => scrollToBottomOfList()} />
295290
<p className="h-2 italic text-gray-400">
296-
{currentlyTyping.length
297-
? `${currentlyTyping.join(', ')} typing...`
291+
{whoIsTypingResult.data?.length
292+
? `${whoIsTypingResult.data.join(', ')} typing...`
298293
: ''}
299294
</p>
300295
</div>

0 commit comments

Comments
 (0)