Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions dist/doboard-widget-bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/doboard-widget-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/doboard-widget-bundle.min.js.map

Large diffs are not rendered by default.

28 changes: 22 additions & 6 deletions js/src/fileuploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FileUploader {
/** @type {HTMLElement|null} */
this.errorMessage = document.getElementById('doboard_task_widget__file-upload__error');

if (!this.fileInput || !this.fileList || !this.errorMessage || this.uploaderWrapper) {
if (!this.fileInput || !this.fileList || !this.errorMessage || !this.uploaderWrapper) {
console.warn('File uploader elements not found');
}
}
Expand Down Expand Up @@ -409,7 +409,12 @@ class FileUploader {
}

async makeScreenshot() {
if (this.files.length >= this.maxFiles || this.getTotalSize() >= this.maxTotalSize) {
if (!this.files || !Array.isArray(this.files) || this.files.length >= this.maxFiles) {
console.log('SpotFix: File count limit reached or file uploader is not fully initialized.');
return;
}

if (typeof this.getTotalSize === 'function' && this.getTotalSize() >= this.maxTotalSize) {
console.log('SpotFix: File count or total size limit reached. Automatic screenshot cancelled.');
return;
}
Expand Down Expand Up @@ -498,13 +503,24 @@ class FileUploader {
lastModified: Date.now(),
});

if (this.validateFile(file)) {
if (this.uploaderWrapper && this.uploaderWrapper.style.display !== 'block') {
if (typeof this.validateFile === 'function' && this.validateFile(file)) {

if (this.uploaderWrapper && this.uploaderWrapper.style && this.uploaderWrapper.style.display !== 'block') {
this.uploaderWrapper.style.display = 'block';
}

this.clearError();
this.addFile(file);
if (typeof this.clearError === 'function') {
this.clearError();
}

try {
if (typeof this.addFile === 'function') {
this.addFile(file);
}
} catch (addFileError) {
console.warn('SpotFix: Cannot add screenshot to DOM (uploader elements missing)', addFileError.message);
}

} else {
console.warn('SpotFix: Automatic screenshot was not added because the total file size would exceed the limit.');
}
Expand Down
12 changes: 9 additions & 3 deletions js/src/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,10 +937,16 @@ class CleanTalkWidgetDoboard {
this.bindCreateTaskEvents(this);
this.bindShowLoginFormEvents();

this.fileUploader = new FileUploader(this.escapeHtml);
this.fileUploader.init();
this.fileUploader = new FileUploader(this?.escapeHtml);
if (this?.fileUploader) {
try {
this.fileUploader.init();
} catch (error) {
console.warn('File uploader init error:', error.message);
}
}

if (!this.nonRequesting && typeof this.fileUploader.makeScreenshot === 'function') {
if (!this?.nonRequesting && this?.fileUploader?.makeScreenshot && typeof this?.fileUploader?.makeScreenshot === 'function') {
const originalDisplay = widgetContainer.style.display;
widgetContainer.style.display = 'none';

Expand Down
Loading