optimization: don't create page if it won't be navigated to

This commit is contained in:
Drew Weymouth
2023-04-30 12:16:35 -07:00
parent 053474f669
commit 118b19aa13
3 changed files with 9 additions and 3 deletions
+4 -1
View File
@@ -7,6 +7,7 @@ import (
type NavigationHandler interface {
SetPage(Page)
CurrentPage() controller.Route
}
type Router struct {
@@ -53,5 +54,7 @@ func (r Router) CreatePage(rte controller.Route) Page {
}
func (r Router) NavigateTo(rte controller.Route) {
r.Nav.SetPage(r.CreatePage(rte))
if rte != r.Nav.CurrentPage() {
r.Nav.SetPage(r.CreatePage(rte))
}
}