mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +00:00
update session database on tab operations
This commit is contained in:
parent
0618233d64
commit
ecbe600fe4
1 changed files with 34 additions and 2 deletions
|
|
@ -63,6 +63,19 @@ class Tab
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->gtk->connect(
|
||||||
|
'page-added',
|
||||||
|
function (
|
||||||
|
?\GtkNotebook $self,
|
||||||
|
?\GtkWidget $child,
|
||||||
|
int $page_num
|
||||||
|
) {
|
||||||
|
$this->reorderPage(
|
||||||
|
null // all
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
$this->gtk->connect(
|
$this->gtk->connect(
|
||||||
'page-removed',
|
'page-removed',
|
||||||
function (
|
function (
|
||||||
|
|
@ -173,7 +186,8 @@ class Tab
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reorderPage(
|
public function reorderPage(
|
||||||
?int $page_num = null
|
?int $page_num = null,
|
||||||
|
bool $session = true
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
// Reorder all pages
|
// Reorder all pages
|
||||||
|
|
@ -192,6 +206,9 @@ class Tab
|
||||||
// Skip deleted
|
// Skip deleted
|
||||||
if ($page_num === -1)
|
if ($page_num === -1)
|
||||||
{
|
{
|
||||||
|
// Prevent session update
|
||||||
|
$session = false;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,8 +216,23 @@ class Tab
|
||||||
$_page[$page_num] = $page;
|
$_page[$page_num] = $page;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reorder
|
// Reorder entities
|
||||||
$this->_page = $_page;
|
$this->_page = $_page;
|
||||||
|
|
||||||
|
// Update session
|
||||||
|
if ($session)
|
||||||
|
{
|
||||||
|
$this->container->browser->database->cleanSession();
|
||||||
|
|
||||||
|
ksort($_page);
|
||||||
|
|
||||||
|
foreach ($_page as $page)
|
||||||
|
{
|
||||||
|
$this->container->browser->database->addSession(
|
||||||
|
$page->navbar->request->getValue()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reorder by $page_num
|
// Reorder by $page_num
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue