Skip to content

Commit

Permalink
Mark users are not typing when they submit messages and close convers…
Browse files Browse the repository at this point in the history
…ations
  • Loading branch information
mfairchild365 committed Aug 25, 2015
1 parent d3f6901 commit adf49c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/UNL/VisitorChat/Assignment/Record.php
Expand Up @@ -119,6 +119,9 @@ public function updateStatus($status)
{
$this->status = $status;

//Make sure that we show them as not typing when their status changes.
$this->is_typing = self::IS_NOT_TYPING;

if (in_array($status, array('LEFT', 'COMPLETED', 'REJECTED', 'EXPIRED', 'FAILED'))) {
$this->date_finished = \UNL\VisitorChat\Controller::epochToDateTime();
}
Expand Down
1 change: 1 addition & 0 deletions src/UNL/VisitorChat/Conversation/Record.php
Expand Up @@ -356,6 +356,7 @@ function close($closeStatus = false, $closerID = false)
$this->status = "CLOSED";
$this->close_status = $closeStatus;
$this->closer_id = $closerID;
$this->client_is_typing = self::CLIENT_IS_NOT_TYPING;
$this->save();

//Close all searching invitations
Expand Down
16 changes: 16 additions & 0 deletions src/UNL/VisitorChat/Message/Edit.php
Expand Up @@ -51,6 +51,22 @@ function handlePost($post = array())
throw new \Exception("You do not have permission to reply to this conversation", 400);
}

if ($user->type == 'client') {
$conversation->client_is_typing = \UNL\VisitorChat\Conversation\Record::CLIENT_IS_NOT_TYPING;
$conversation->save();
} else {
//Stop typing status for the assignment
foreach ($conversation->getAcceptedAssignments() as $assignment) {
if ($assignment->users_id != $user->id) {
continue;
}

$assignment->is_typing = \UNL\VisitorChat\Assignment\Record::IS_NOT_TYPING;
$assignment->save();
break;
}
}

$this->users_id = $user->id;
$this->date_created = \UNL\VisitorChat\Controller::epochToDateTime();

Expand Down

0 comments on commit adf49c7

Please sign in to comment.