mirror of
https://github.com/makew0rld/amfora.git
synced 2024-12-04 14:46:29 -05:00
Fix tab number and favicons when moving through history
This commit is contained in:
parent
fce6aef1cb
commit
27a041a746
@ -91,11 +91,10 @@ func handleOther(u string) {
|
||||
}
|
||||
|
||||
// handleFavicon handles getting and displaying a favicon.
|
||||
// `old` is the previous favicon for the tab.
|
||||
func handleFavicon(t *tab, host, old string) {
|
||||
func handleFavicon(t *tab, host string) {
|
||||
defer func() {
|
||||
// Update display if needed
|
||||
if t.page.Favicon != old && isValidTab(t) {
|
||||
if t.page.Favicon != "" && isValidTab(t) {
|
||||
browser.SetTabLabel(strconv.Itoa(tabNumber(t)), t.page.Favicon)
|
||||
App.Draw()
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package display
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/makeworld-the-better-one/amfora/renderer"
|
||||
@ -103,20 +104,23 @@ func setPage(t *tab, p *structs.Page) {
|
||||
// Make sure the page content is fitted to the terminal every time it's displayed
|
||||
reformatPage(p)
|
||||
|
||||
oldFav := t.page.Favicon
|
||||
|
||||
t.page = p
|
||||
|
||||
go func() {
|
||||
parsed, _ := url.Parse(p.URL)
|
||||
handleFavicon(t, parsed.Host, oldFav)
|
||||
}()
|
||||
|
||||
// Change page on screen
|
||||
t.view.SetText(p.Content)
|
||||
t.view.Highlight("") // Turn off highlights, other funcs may restore if necessary
|
||||
t.view.ScrollToBeginning()
|
||||
|
||||
// Set tab number in case a favicon from before overwrote it
|
||||
tabNum := tabNumber(t)
|
||||
browser.SetTabLabel(strconv.Itoa(tabNum), strconv.Itoa(tabNum+1))
|
||||
App.Draw()
|
||||
|
||||
go func() {
|
||||
parsed, _ := url.Parse(p.URL)
|
||||
handleFavicon(t, parsed.Host)
|
||||
}()
|
||||
|
||||
// Setup display
|
||||
App.SetFocus(t.view)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user