]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6482
authorsoufiane <soufiane@cubedesigners.com>
Thu, 4 Jan 2024 16:49:57 +0000 (17:49 +0100)
committersoufiane <soufiane@cubedesigners.com>
Thu, 4 Jan 2024 16:49:57 +0000 (17:49 +0100)
app/Http/Controllers/Admin/Operations/FluidbookPublication/LinksOperation.php
resources/linkeditor/js/linkeditor.js

index 4e5a2156c36eaabe8f11dd634d22c58812f85070..9e68829def189762e89f0fd597a2d1eae69990a8 100644 (file)
@@ -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]]);
         }
 
index 675508f446704737a82456ee8838b184ef15312a..90114e14aa046f317c6b5ed2b98ef901f23fceb4 100644 (file)
@@ -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")