Skip to content

Commit f3d20e3

Browse files
committed
Retrieve canvases from the cache when possible instead of downloading and rendering the code again
1 parent 8cc8eb4 commit f3d20e3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

octoprint_gcodethumbs/static/js/gcode-preview-viewmodel.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ $(function() {
3535
if (elements.length)
3636
enrichWithPreview(elements[0]);
3737
else
38-
timer = setTimeout(monitorDom, 1000);
38+
timer = setTimeout(monitorDom, 100);
3939
}
4040

4141
function getElements() {
@@ -89,8 +89,14 @@ $(function() {
8989

9090
function enrichWithPreview(element) {
9191
const filename = extractKey(element);
92-
downloading = true;
92+
93+
if (previews[filename]) {
94+
insertAfter(previews[filename].canvas, element.querySelector('.title'));
95+
timer = setTimeout(monitorDom, 10);
96+
return;
97+
}
9398

99+
downloading = true;
94100
console.log('[GCodePreview] downloading ' + filename);
95101

96102
// TODO: show spinner while downloading

0 commit comments

Comments
 (0)