skip add same request value on history argument enabled

This commit is contained in:
yggverse 2024-09-14 01:08:12 +03:00
parent a8c59d5642
commit 2c144c3182
5 changed files with 54 additions and 3 deletions

View File

@ -161,10 +161,20 @@ void Page::navigation_reload(
// Update navigation history?
if (ADD_HISTORY)
{
pageNavigation->history_add(
pageNavigation->get_request_text(),
true
// Skip same
Glib::ustring request;
pageNavigation->try_history_current(
request
);
if (request != pageNavigation->get_request_text())
{
pageNavigation->history_add(
pageNavigation->get_request_text(),
true
);
}
}
// Reset page data

View File

@ -209,6 +209,21 @@ bool Navigation::try_history_back(
return false;
}
bool Navigation::try_history_current(
Glib::ustring & request
) {
navigation::History::Memory match;
if (navigationHistory->try_current(match))
{
request = match.request;
return true;
}
return false;
}
bool Navigation::try_history_forward(
Glib::ustring & request,
const bool & UPDATE_MEMORY_INDEX

View File

@ -112,6 +112,10 @@ namespace app::browser::main::tab::page
const bool & UPDATE_MEMORY_INDEX
);
bool try_history_current(
Glib::ustring & request
);
bool try_history_forward(
Glib::ustring & request,
const bool & UPDATE_MEMORY_INDEX

View File

@ -189,6 +189,24 @@ bool History::try_back(
}
}
bool History::try_current(
Memory & match
) {
try
{
match = memory.at(
index
);
return true;
}
catch (std::out_of_range)
{
return false;
}
}
bool History::try_forward(
Memory & match,
const bool & UPDATE_MEMORY_INDEX

View File

@ -117,6 +117,10 @@ namespace app::browser::main::tab::page::navigation
const bool & UPDATE_MEMORY_INDEX
);
bool try_current(
Memory & match
);
bool try_forward(
Memory & match,
const bool & UPDATE_MEMORY_INDEX