From aa3de2980c7fd03c978dc5915b3dfe5468f15789 Mon Sep 17 00:00:00 2001 From: yggverse Date: Thu, 18 Jul 2024 15:26:55 +0300 Subject: [PATCH] refresh header by new title if current page is active --- src/Entity/Browser/Container/Page.php | 26 +++++++++++++++++++ src/Entity/Browser/Container/Page/Content.php | 13 +++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/src/Entity/Browser/Container/Page.php b/src/Entity/Browser/Container/Page.php index cfbb09ca..eb68661d 100644 --- a/src/Entity/Browser/Container/Page.php +++ b/src/Entity/Browser/Container/Page.php @@ -184,6 +184,15 @@ class Page $connection->getTooltip() ); + // Refresh header by new title if current page is active + if ($this == $this->container->tab->getPage()) + { + $this->container->browser->header->setTitle( + $this->title->getValue(), + $this->title->getSubtitle() + ); + } + // Show response form $this->response->show( $request['placeholder'], @@ -209,6 +218,15 @@ class Page $connection->getTooltip() ); + // Refresh header by new title if current page is active + if ($this == $this->container->tab->getPage()) + { + $this->container->browser->header->setTitle( + $this->title->getValue(), + $this->title->getSubtitle() + ); + } + // Update content $this->content->set( $connection->getMime(), @@ -233,6 +251,14 @@ class Page _('Timeout') ); + // Refresh header by new title if current page is active + if ($this == $this->container->tab->getPage()) + { + $this->container->browser->header->setTitle( + $this->title->getValue() + ); + } + // Update content $this->content->set( Filesystem::MIME_TEXT_PLAIN, diff --git a/src/Entity/Browser/Container/Page/Content.php b/src/Entity/Browser/Container/Page/Content.php index f44af7d2..b527db88 100644 --- a/src/Entity/Browser/Container/Page/Content.php +++ b/src/Entity/Browser/Container/Page/Content.php @@ -81,11 +81,22 @@ class Content $title ); - if ($title) // use gemtext title on available + // Update title by gemtext H1 tag (on available) + if ($title) { + // Set new title $this->page->title->setValue( $title ); + + // Refresh header by new title if current page is active + if ($this->page == $this->page->container->tab->getPage()) + { + $this->page->container->browser->header->setTitle( + $this->page->title->getValue(), + $this->page->title->getSubtitle() + ); + } } break;