Skip to content

Commit 5ed6bcb

Browse files
committed
Fix: init performance fix - do resize only for new screenshots.
1 parent 997afcd commit 5ed6bcb

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

app.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func main() {
7373
row := d.CreateElement("div").(*dom.HTMLDivElement)
7474
row.SetClass("row row-link")
7575

76-
addScreenshot(d, row, link.Screenshot)
76+
addScreenshot(d, row, link.Screenshot, false)
7777
addTitle(d, row, link.Id, link.Url, link.Title)
7878
addRowButtons(d, rows, row, link.Id, link.Url)
7979

@@ -101,7 +101,7 @@ func main() {
101101
nextId = urls[len(urls)-1].Id + 1
102102
}
103103

104-
addScreenshot(d, row, screenshot)
104+
addScreenshot(d, row, screenshot, true)
105105
addTitle(d, row, nextId, currentUrl, tab.Title)
106106
addRowButtons(d, rows, row, nextId, currentUrl)
107107

@@ -115,14 +115,20 @@ func main() {
115115
})
116116
}
117117

118-
func addScreenshot(d dom.Document, row *dom.HTMLDivElement, screenshot string) {
118+
func addScreenshot(d dom.Document, row *dom.HTMLDivElement, screenshot string, newScreenshot bool) {
119119
div := d.CreateElement("div").(*dom.HTMLDivElement)
120120
div.SetClass("col-6 d-flex flex-column")
121121
row.AppendChild(div)
122122

123123
img := d.CreateElement("img").(*dom.HTMLImageElement)
124124
img.SetClass("thumbnail")
125-
img.Src = resizeScreenshot(screenshot)
125+
126+
if newScreenshot {
127+
img.Src = resizeScreenshot(screenshot)
128+
} else {
129+
img.Src = screenshot
130+
}
131+
126132
div.AppendChild(img)
127133
}
128134

0 commit comments

Comments
 (0)