Skip to content

Commit

Permalink
Fixed the typing event
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed May 31, 2024
1 parent afd48b8 commit 9959f1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/Livewire/SendMessageInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public function mount($selectedUser): void
$this->loggedInUser = Auth::user();
}

public function updating($newMessage): void
{
$this->dispatch('typing', ['isTyping' => !empty($newMessage)]);
}

public function removeAttachment($name): void
{
$this->attachments = $this->attachments->filter(function ($attachment) use ($name) {
Expand Down
5 changes: 5 additions & 0 deletions resources/views/livewire/send-message-input.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ function sendMessage() {
}
}
//'typing', ['isTyping' => !empty($newMessage)]);
Livewire.on('typing', (isTyping) => {
socket.emit('typing', { isTyping, from: authUser.name, to: receiver.name });
});
Livewire.on('messagesSent', () => {
document.getElementById('messageInput').value = '';
});
Expand Down

0 comments on commit 9959f1e

Please sign in to comment.