Browse Source

skip add same request value on history argument enabled

CPP-GTK4
yggverse 2 months ago
parent
commit
2c144c3182
  1. 16
      src/app/browser/main/tab/page.cpp
  2. 15
      src/app/browser/main/tab/page/navigation.cpp
  3. 4
      src/app/browser/main/tab/page/navigation.hpp
  4. 18
      src/app/browser/main/tab/page/navigation/history.cpp
  5. 4
      src/app/browser/main/tab/page/navigation/history.hpp

16
src/app/browser/main/tab/page.cpp

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

15
src/app/browser/main/tab/page/navigation.cpp

@ -209,6 +209,21 @@ bool Navigation::try_history_back(
return false; 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( bool Navigation::try_history_forward(
Glib::ustring & request, Glib::ustring & request,
const bool & UPDATE_MEMORY_INDEX const bool & UPDATE_MEMORY_INDEX

4
src/app/browser/main/tab/page/navigation.hpp

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

18
src/app/browser/main/tab/page/navigation/history.cpp

@ -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( bool History::try_forward(
Memory & match, Memory & match,
const bool & UPDATE_MEMORY_INDEX const bool & UPDATE_MEMORY_INDEX

4
src/app/browser/main/tab/page/navigation/history.hpp

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

Loading…
Cancel
Save