Skip to content

Commit

Permalink
Load methods return dataId, fixes #1860
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Feb 3, 2025
1 parent 9c2c134 commit 09c9b95
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ export class App {
* Load a list of files. Can be image files or a state file.
*
* @param {File[]} files The list of files to load.
* @returns {string} The data ID, '-1' if problem.
* @fires App#loadstart
* @fires App#loadprogress
* @fires App#loaditem
Expand All @@ -768,13 +769,13 @@ export class App {
* @function
*/
loadFiles = (files) => {
// Get new data id
const dataId = this.#dataController.getNextDataId();
if (files.length === 0) {
logger.warn('Ignoring empty input file list.');
return;
return '-1';
}
const dataId = this.#dataController.getNextDataId();
this.#loadController.loadFiles(files, dataId);
return dataId;
};

/**
Expand All @@ -785,6 +786,7 @@ export class App {
* - requestHeaders: an array of {name, value} to use as request headers,
* - withCredentials: boolean xhr.withCredentials flag to pass to the request,
* - batchSize: the size of the request url batch.
* @returns {string} The data ID, '-1' if problem.
* @fires App#loadstart
* @fires App#loadprogress
* @fires App#loaditem
Expand All @@ -794,13 +796,13 @@ export class App {
* @function
*/
loadURLs = (urls, options) => {
// Get new data id
const dataId = this.#dataController.getNextDataId();
if (urls.length === 0) {
logger.warn('Ignoring empty input url list.');
return;
return '-1';
}
const dataId = this.#dataController.getNextDataId();
this.#loadController.loadURLs(urls, dataId, options);
return dataId;
};

/**
Expand Down Expand Up @@ -837,6 +839,7 @@ export class App {
*
* @param {Array} data The list of ArrayBuffers to load
* in the form of [{name: "", filename: "", data: data}].
* @returns {string} The data ID.
* @fires App#loadstart
* @fires App#loadprogress
* @fires App#loaditem
Expand All @@ -846,9 +849,9 @@ export class App {
* @function
*/
loadImageObject = (data) => {
// Get new data id
const dataId = this.#dataController.getNextDataId();
this.#loadController.loadImageObject(data, dataId);
return dataId;
};

/**
Expand Down

0 comments on commit 09c9b95

Please sign in to comment.