$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]);
}
// 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]]);
}
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")