async listMaps()

in examples/demo-app/src/cloud-providers/dropbox/dropbox-provider.js [135:167]


  async listMaps() {
    // list files
    try {
      // https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesListFolder__anchor
      const response = await this._dropbox.filesListFolder({
        path: this._path
      });
      const {pngs, visualizations} = this._parseEntries(response);
      // https://dropbox.github.io/dropbox-sdk-js/Dropbox.html#filesGetThumbnailBatch__anchor
      // up to 25 per request
      // TODO: implement pagination, so we don't need to get all the thumbs all at once
      const thumbnails = await Promise.all(this._getThumbnailRequests(pngs)).then(results =>
        results.reduce((accu, r) => [...accu, ...(r.entries || [])], [])
      );

      // append to visualizations
      thumbnails &&
        thumbnails.forEach(thb => {
          if (thb['.tag'] === 'success' && thb.thumbnail) {
            const matchViz = visualizations[pngs[thb.metadata.id] && pngs[thb.metadata.id].name];
            if (matchViz) {
              matchViz.thumbnail = `${IMAGE_URL_PREFIX}${thb.thumbnail}`;
            }
          }
        });

      // dropbox returns
      return Object.values(visualizations).reverse();
    } catch (error) {
      // made the error message human readable for provider updater
      throw this._handleDropboxError(error);
    }
  }