From: soufiane Date: Thu, 4 Jan 2024 16:49:57 +0000 (+0100) Subject: wait #6482 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=be2fff8b3cf527bba4cabb927ec4c9565fc2ad49;p=fluidbook-toolbox.git wait #6482 --- diff --git a/app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php b/app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php index 4e5a2156c..9e68829de 100644 --- a/app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php +++ b/app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php @@ -303,34 +303,38 @@ trait LinksOperation $userId = backpack_user()->id; $unload = $request->unload; - /*cache()->forget('queue_editor'.$fluidbookId);*/ + /*cache()->forget('queue_editor'.$fluidbookId); /*cache()->forget('connexion'.$fluidbookId);*/ /* Reset * - */ + */ if(!cache()->has('queue_editor'.$fluidbookId)) { $entries = [["token" => $token, "date" => now()]]; cache(['queue_editor'.$fluidbookId => $entries]); } else { $queueEditor = cache()->get('queue_editor'.$fluidbookId); // on récupère la liste des onglets - $key = key(array_filter($queueEditor, function($n) use($token) { return $n["token"] === $token; })); + $connexion = array_filter($queueEditor, function($n) use($token) { return $n["token"] === $token; }); + $key = key($connexion); + //dump($queueEditor); if ((int)$unload === 1 && $key) { unset($queueEditor[$key]); // on supprime l'onglet de la liste au chargement ou à sa fermeture } + if(!$key) { $queueEditor[] = ["token" => $token, "date" => now()]; } else { + $queueEditor[$key]["token"] = $token; $queueEditor[$key]["date"] = now(); } + + // on supprime les connexions afk $queueEditor = array_filter($queueEditor, function($n) { - return strtotime($n["date"]) > strtotime(now())-20; + return strtotime($n["date"]) > strtotime(now())-10; }); - //$queueEditor = array_unique($queueEditor); - cache(['queue_editor'.$fluidbookId => $queueEditor]); } @@ -339,10 +343,10 @@ trait LinksOperation // réinitialiser la connexion courante quand on clique sur "déconnecter l'utilisateur" if($request->clear) { - $key = key(array_filter($queueEditor, function($n) use($token) { return $n["token"] === $token; })); - $queueEditor = array_slice($queueEditor, $key, 1); - $queueEditor = array_merge($queueEditor[$key],$queueEditor); - cache(['queue_editor'.$fluidbookId => $queueEditor]); + $queueEditorCurrent = $queueEditor[$key]; + unset($queueEditor[$key]); + $queueEditor = array_merge([$queueEditorCurrent], $queueEditor); + cache(['queue_editor' . $fluidbookId => $queueEditor]); cache(['connexion' . $fluidbookId => ['id' => $userId, 'token' => $token, 'f_id' => $fluidbookId]]); } diff --git a/resources/linkeditor/js/linkeditor.js b/resources/linkeditor/js/linkeditor.js index 675508f44..90114e14a 100644 --- a/resources/linkeditor/js/linkeditor.js +++ b/resources/linkeditor/js/linkeditor.js @@ -587,8 +587,7 @@ $(function () { data: {id: FLUIDBOOK_DATA.id, token: token_ ?? token, unload: unload, clear: clear} }).done(function (msg) { let response = JSON.parse(msg) - console.log(response) - console.log(response.queueEditor, response.token) + console.log(response.queueEditor) if (response.status === "unavailable" ) { if ($("#popup-overlay").find('.popup').length === 0) { $("#popup-overlay").addClass("show")