mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 09:35:28 +00:00
fix response expiration event
This commit is contained in:
parent
1079da78b5
commit
5c2aeec8cc
2 changed files with 20 additions and 11 deletions
|
|
@ -105,7 +105,8 @@ class Page
|
||||||
|
|
||||||
public function update(
|
public function update(
|
||||||
bool $history = true,
|
bool $history = true,
|
||||||
int $refresh = 100
|
int $refresh = 100,
|
||||||
|
int $timeout = 5
|
||||||
): void
|
): void
|
||||||
{
|
{
|
||||||
// Update history
|
// Update history
|
||||||
|
|
@ -133,13 +134,17 @@ class Page
|
||||||
|
|
||||||
// Update content by multi-protocol responser
|
// Update content by multi-protocol responser
|
||||||
$response = new \Yggverse\Yoda\Model\Response(
|
$response = new \Yggverse\Yoda\Model\Response(
|
||||||
$this->navbar->request->getValue()
|
$this->navbar->request->getValue(),
|
||||||
|
$timeout
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Calculate expiration time
|
||||||
|
$expire = time() + $timeout;
|
||||||
|
|
||||||
// Listen response
|
// Listen response
|
||||||
\Gtk::timeout_add(
|
\Gtk::timeout_add(
|
||||||
$refresh,
|
$refresh,
|
||||||
function() use ($response)
|
function() use ($response, $expire)
|
||||||
{
|
{
|
||||||
// Redirect requested
|
// Redirect requested
|
||||||
if ($location = $response->getRedirect())
|
if ($location = $response->getRedirect())
|
||||||
|
|
@ -205,8 +210,18 @@ class Page
|
||||||
|
|
||||||
else $this->response->hide();
|
else $this->response->hide();
|
||||||
|
|
||||||
// Stop event loop on request expired or completed
|
// Stop event loop on request completed
|
||||||
if ($response->isExpired() || $response->isCompleted())
|
if ($response->isCompleted())
|
||||||
|
{
|
||||||
|
// Hide progressbar
|
||||||
|
$this->progressbar->hide();
|
||||||
|
|
||||||
|
// Stop
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop event loop on request expired
|
||||||
|
if (time() > $expire)
|
||||||
{
|
{
|
||||||
// Hide progressbar
|
// Hide progressbar
|
||||||
$this->progressbar->hide();
|
$this->progressbar->hide();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ class Response
|
||||||
|
|
||||||
// Async status
|
// Async status
|
||||||
private bool $_completed = false;
|
private bool $_completed = false;
|
||||||
private bool $_expired = false;
|
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
private ?string $_title = null;
|
private ?string $_title = null;
|
||||||
|
|
@ -293,11 +292,6 @@ class Response
|
||||||
return $this->_completed;
|
return $this->_completed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isExpired(): bool
|
|
||||||
{
|
|
||||||
return $this->_expired;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTitle(): ?string
|
public function getTitle(): ?string
|
||||||
{
|
{
|
||||||
return $this->_title;
|
return $this->_title;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue