Skip to content

Commit

Permalink
feat(subscriptions): connection state (#6084)
Browse files Browse the repository at this point in the history
  • Loading branch information
KATT authored Oct 20, 2024
1 parent 71fadaf commit 879d6bb
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,7 @@ export default function IndexPage() {
},
});

const [currentlyTyping, setCurrentlyTyping] = useState<string[]>([]);
trpc.post.whoIsTyping.useSubscription(undefined, {
onData(data) {
setCurrentlyTyping(data);
},
});
const whoIsTypingResult = trpc.post.whoIsTyping.useSubscription();

return (
<>
Expand Down Expand Up @@ -293,8 +288,8 @@ export default function IndexPage() {
<div className="w-full">
<AddMessageForm onMessagePost={() => scrollToBottomOfList()} />
<p className="h-2 italic text-gray-400">
{currentlyTyping.length
? `${currentlyTyping.join(', ')} typing...`
{whoIsTypingResult.data?.length
? `${whoIsTypingResult.data.join(', ')} typing...`
: ''}
</p>
</div>
Expand Down

0 comments on commit 879d6bb

Please sign in to comment.