Skip to content

Commit 86c3c01

Browse files
committed
Do not keep trying to load a file when an error occurs
1 parent 994a04c commit 86c3c01

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ $(function() {
44

55
var self = this;
66
var downloading = false;
7+
var errors = {};
78

89
self.filesViewModel = parameters[0];
910
console.log(self.filesViewModel);
@@ -25,7 +26,8 @@ $(function() {
2526

2627
const elements = getElements()
2728
.filter( isVisible )
28-
.filter( elementNeedsPreview );
29+
.filter( elementNeedsPreview )
30+
.filter( hasNotErrored) ;
2931

3032
console.log('[monitor] ', elements.length, ' elements queued');
3133

@@ -49,6 +51,11 @@ $(function() {
4951
return !element.querySelector('canvas');
5052
}
5153

54+
function hasNotErrored(element) {
55+
const filename = extractKey(element);
56+
return !errors[filename];
57+
}
58+
5259
// TODO: include device and parent folder(s) to ensure uniqueness
5360
function extractKey(element) {
5461
return element.querySelector('.title').innerText;
@@ -90,8 +97,10 @@ $(function() {
9097
insertAfter(canvas, element.querySelector('.title'))
9198
}
9299
})
93-
.catch(function() {
100+
.catch(function(e) {
101+
console.warn('error while getting file', e)
94102
downloading = false;
103+
errors[filename] = e;
95104
});
96105
}
97106

0 commit comments

Comments
 (0)