From 64ae36eecf268d64d8c64d783b7fa15784becfa7 Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 17 Apr 2024 10:45:47 +0300 Subject: [PATCH] add page history save mode --- config.json | 6 +++++- src/Entity/Tab/History.php | 26 ++++++++++++++++++++++++++ src/Entity/Tab/Page.php | 2 +- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 593059f..19c2af5 100644 --- a/config.json +++ b/config.json @@ -86,7 +86,11 @@ }, "database": { - "enabled":true + "enabled":true, + "mode": + { + "renew":true + } } }, "progressbar": diff --git a/src/Entity/Tab/History.php b/src/Entity/Tab/History.php index 01d2991..0528beb 100644 --- a/src/Entity/Tab/History.php +++ b/src/Entity/Tab/History.php @@ -343,6 +343,32 @@ class History $this->treeview->show_all(); } + public function add( + string $url, + ?string $title = null, + bool $renew = false // delete previous records with same URL + ): ?int + { + if ($renew) + { + foreach ($this->app->database->getHistory($url) as $record) + { + $this->app->database->deleteHistory( + $record->id + ); + } + } + + $id = $this->app->database->addHistory( + $url, + $title + ); + + $this->refresh(); + + return $id; + } + public function getSelectedColumn( int $column, \GtkTreeView $treeview = null diff --git a/src/Entity/Tab/Page.php b/src/Entity/Tab/Page.php index 7373277..fba2a71 100644 --- a/src/Entity/Tab/Page.php +++ b/src/Entity/Tab/Page.php @@ -711,7 +711,7 @@ class Page $this->app->history->add( $url, $title, - $this->config->history->database->renew + $this->config->history->database->mode->renew ); } }