From 480bd7a89df78e6ef3d74c8d448874a049c1fcfb Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Tue, 16 May 2023 17:27:39 -0700 Subject: [PATCH] don't add 'blank page' to navigation history --- ui/browsing/browsingpane.go | 34 ++++++++++++---------------------- ui/controller/routes.go | 2 +- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index ae1ec37..362e4e5 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -88,13 +88,17 @@ func NewBrowsingPane(app *backend.App) *BrowsingPane { func (b *BrowsingPane) SetPage(p Page) { if p == nil { - b.doSetPage(&blankPage{}) - return - } - oldPage := b.curPage - if b.doSetPage(p) && oldPage != nil { - b.addPageToHistory(oldPage, true) - b.updateHistoryButtons() + // special case to set a "blank page" + // only used on logout, in conjunction with clearing the history + b.pageContainer.Objects[1] = layout.NewSpacer() + b.curPage = nil + b.pageContainer.Refresh() + } else { + oldPage := b.curPage + if b.doSetPage(p) && oldPage != nil { + b.addPageToHistory(oldPage, true) + b.updateHistoryButtons() + } } } @@ -225,7 +229,7 @@ func (b *BrowsingPane) Reload() { func (b *BrowsingPane) CurrentPage() controller.Route { if b.curPage == nil { - return controller.Route{Page: controller.Blank} + return controller.Route{Page: controller.None} } return b.curPage.Route() } @@ -233,17 +237,3 @@ func (b *BrowsingPane) CurrentPage() controller.Route { func (b *BrowsingPane) CreateRenderer() fyne.WidgetRenderer { return widget.NewSimpleRenderer(b.container) } - -type blankPage struct { - layout.Spacer -} - -var _ Page = (*blankPage)(nil) - -func (p *blankPage) Reload() {} - -func (p *blankPage) Route() controller.Route { return controller.Route{Page: controller.Blank} } - -func (p *blankPage) Save() SavedPage { return p } - -func (p *blankPage) Restore() Page { return p } diff --git a/ui/controller/routes.go b/ui/controller/routes.go index 927a862..dc2255a 100644 --- a/ui/controller/routes.go +++ b/ui/controller/routes.go @@ -3,7 +3,7 @@ package controller type PageName int const ( - Blank PageName = iota + None PageName = iota // nil case Album Albums Artist