Pārlūkot izejas kodu

Merge pull request #277 from transloadit/instagram-carousels

Instagram carousels
Artur Paikin 7 gadi atpakaļ
vecāks
revīzija
2a4d6ad5be
2 mainītis faili ar 19 papildinājumiem un 5 dzēšanām
  1. 2 2
      CHANGELOG.md
  2. 17 3
      src/plugins/Instagram/index.js

+ 2 - 2
CHANGELOG.md

@@ -104,6 +104,7 @@ Theme: Dogumentation.
 - [x] xhrupload: add XHRUpload a more flexible successor to Multipart, so that S3 plugin can depend on it (@goto-bus-stop #242)
 - [x] xhrupload: add XHRUpload a more flexible successor to Multipart, so that S3 plugin can depend on it (@goto-bus-stop #242)
 - [x] core: add getFile method (@goto-bus-stop, #263)
 - [x] core: add getFile method (@goto-bus-stop, #263)
 - [x] provider: use informer to display errors (@ifedapoolarewaju)
 - [x] provider: use informer to display errors (@ifedapoolarewaju)
+- [x] provider: flatten instagram carousels #234 (@ifedapoolarewaju)
 - [x] server: add uppy-server url as `i-am` header (@ifedapoolarewaju)
 - [x] server: add uppy-server url as `i-am` header (@ifedapoolarewaju)
 - [x] server: disable socket channel from restarting an already completed file download (@ifedapoolarewaju)
 - [x] server: disable socket channel from restarting an already completed file download (@ifedapoolarewaju)
 - [x] server: make uppy client whitelisting optional. You may use wildcard instead (@ifedapoolarewaju)
 - [x] server: make uppy client whitelisting optional. You may use wildcard instead (@ifedapoolarewaju)
@@ -120,8 +121,7 @@ Theme: Dogumentation.
 - [x] tus: return immediately if no files are selected (@goto-bus-stop #245)
 - [x] tus: return immediately if no files are selected (@goto-bus-stop #245)
 - [x] uppy-server: add uppy-server metrics to Librato (@ifedapoolarewaju @kiloreux)
 - [x] uppy-server: add uppy-server metrics to Librato (@ifedapoolarewaju @kiloreux)
 - [x] webcam: add 1, 2, 3, smile! to webcam, onBeforeSnapshothook (@arturi, #187, #248)
 - [x] webcam: add 1, 2, 3, smile! to webcam, onBeforeSnapshothook (@arturi, #187, #248)
-- [x] website: live example on the homepage, “try me” (@arturi)
-- [x] website: improve examples a little (@arturi)
+- [x] website: live example on the homepage, “try me” button, improve /examples (@arturi)
 
 
 ## 0.17.0
 ## 0.17.0
 
 

+ 17 - 3
src/plugins/Instagram/index.js

@@ -91,7 +91,20 @@ module.exports = class Instagram extends Plugin {
   }
   }
 
 
   getItemSubList (item) {
   getItemSubList (item) {
-    return item.data
+    const subItems = []
+    item.data.forEach((subItem) => {
+      if (subItem.carousel_media) {
+        subItem.carousel_media.forEach((i, index) => {
+          const { id, created_time } = subItem
+          const newSubItem = Object.assign({}, i, { id, created_time })
+          newSubItem.carousel_id = index
+          subItems.push(newSubItem)
+        })
+      } else {
+        subItems.push(subItem)
+      }
+    })
+    return subItems
   }
   }
 
 
   getItemName (item) {
   getItemName (item) {
@@ -103,11 +116,12 @@ module.exports = class Instagram extends Plugin {
   }
   }
 
 
   getItemId (item) {
   getItemId (item) {
-    return item.id
+    return `${item.id}${item.carousel_id || ''}`
   }
   }
 
 
   getItemRequestPath (item) {
   getItemRequestPath (item) {
-    return this.getItemId(item)
+    const suffix = isNaN(item.carousel_id) ? '' : `?carousel_id=${item.carousel_id}`
+    return `${item.id}${suffix}`
   }
   }
 
 
   getItemModifiedDate (item) {
   getItemModifiedDate (item) {