1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-24 19:33:07 +01:00

Trigger conversation.view.start when focus returns to conversation

This commit is contained in:
FreeScout 2020-11-20 22:41:51 -08:00
parent 00b52794aa
commit 4f1c2731bf
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@
namespace App\Providers;
use App\Conversation;
use App\Notifications\BroadcastNotification;
use Carbon\Carbon;
use Illuminate\Broadcasting\BroadcastManager;
@ -118,6 +119,13 @@ class PolycastServiceProvider extends ServiceProvider
$viewing_conversation_id = null;
if (!empty($request->data) && !empty($request->data['conversation_id'])) {
$viewing_conversation_id = $request->data['conversation_id'];
if (!empty($request->data['conversation_view_start'])) {
$conversation = Conversation::find($request->data['conversation_id']);
if ($conversation) {
\Eventy::action('conversation.view.start', $conversation);
}
}
}
if ($viewing_conversation_id) {

5
public/js/main.js vendored
View File

@ -18,6 +18,7 @@ var fs_in_app_data = {};
var fs_actions = {};
var fs_filters = {};
var fs_body_default = '<div><br></div>';
var fs_prev_focus = true;
// Ajax based notifications;
var poly;
@ -2965,6 +2966,10 @@ function polycastInit()
} else {
data.replying = 0;
}
if (!fs_prev_focus && document.hasFocus()) {
data.conversation_view_start = 1;
}
fs_prev_focus = document.hasFocus();
// If conversation_id is passed it means that user is viewing the converation
if (document.hasFocus() || data.replying) {
data.conversation_id = getGlobalAttr('conversation_id');