mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-02-06 00:14:13 +00:00
add new history record on request changed only
This commit is contained in:
parent
d3d6e859f0
commit
b00e5befde
@ -95,7 +95,15 @@ impl Page {
|
||||
&request, true, // activate (page reload)
|
||||
);
|
||||
|
||||
navigation.history_add(request);
|
||||
// Add new history record on request change
|
||||
match navigation.history_current() {
|
||||
Some(current) => {
|
||||
if current != request {
|
||||
navigation.history_add(request);
|
||||
}
|
||||
}
|
||||
None => navigation.history_add(request),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -93,6 +93,10 @@ impl Navigation {
|
||||
self.history.back(follow_to_index)
|
||||
}
|
||||
|
||||
pub fn history_current(&self) -> Option<GString> {
|
||||
self.history.current()
|
||||
}
|
||||
|
||||
pub fn history_forward(&self, follow_to_index: bool) -> Option<GString> {
|
||||
self.history.forward(follow_to_index)
|
||||
}
|
||||
|
@ -92,6 +92,16 @@ impl History {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn current(&self) -> Option<GString> {
|
||||
let index = self.index.borrow().clone(); // keep outside as borrow
|
||||
if let Some(usize) = index {
|
||||
if let Some(memory) = self.memory.borrow().get(usize) {
|
||||
return Some(memory.request.clone());
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn forward(&self, follow_to_index: bool) -> Option<GString> {
|
||||
let index = self.index.borrow().clone(); // keep outside as borrow
|
||||
if let Some(usize) = index {
|
||||
|
Loading…
x
Reference in New Issue
Block a user