javascript: add some comments to the upload systems

This commit is contained in:
Pierre de La Morinerie 2020-01-08 18:15:03 +01:00
parent 2a1c91a2a5
commit a1083ca253
3 changed files with 10 additions and 1 deletions

View file

@ -27,6 +27,8 @@ addUploadEventListener(INITIALIZE_EVENT, ({ target, detail: { id, file } }) => {
addUploadEventListener(START_EVENT, ({ target, detail: { id } }) => {
ProgressBar.start(id);
// At the end of the upload, the form will be submitted again.
// Avoid the confirm dialog to be presented again then.
const button = target.form.querySelector('button.primary');
if (button) {
button.removeAttribute('data-confirm');

View file

@ -3,7 +3,7 @@ import ProgressBar from './progress-bar';
/**
Uploader class is a delegate for DirectUpload instance
used to track lifecycle and progress of un upload.
used to track lifecycle and progress of an upload.
*/
export default class Uploader {
constructor(input, file, directUploadUrl) {

View file

@ -29,6 +29,13 @@ delegate('click', '[data-attachment-refresh]', event => {
attachementPoller.check();
});
// Periodically check the state of a set of URLs.
//
// Each time the given URL is requested, the matching `show.js.erb` view is rendered,
// causing the state to be refreshed.
//
// This is used mainly to refresh attachments during the anti-virus check,
// but also to refresh the state of a pending spreadsheet export.
class RemotePoller {
urls = new Set();
timeout;