ソースを参照

try to use AsyncStorage with Instagram

Artur Paikin 6 年 前
コミット
d8205de2dc
1 ファイル変更23 行追加15 行削除
  1. 23 15
      examples/react-native-expo/react-native/file-picker/provider.js

+ 23 - 15
examples/react-native-expo/react-native/file-picker/provider.js

@@ -3,11 +3,15 @@ import React from 'react'
 import {
 import {
   // StyleSheet,
   // StyleSheet,
   // FlatList,
   // FlatList,
-  // View,
   // Image,
   // Image,
+  // TouchableOpacity,
+  // Text,
+  // TextInput,
+  // View,
+  AsyncStorage,
   WebView } from 'react-native'
   WebView } from 'react-native'
-
 import Instagram from '@uppy/instagram'
 import Instagram from '@uppy/instagram'
+import Url from './url'
 
 
 function getQueryParamValueFromUrl (name, url) {
 function getQueryParamValueFromUrl (name, url) {
   name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]')
   name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]')
@@ -17,7 +21,7 @@ function getQueryParamValueFromUrl (name, url) {
   return results == null ? null : results[1]
   return results == null ? null : results[1]
 }
 }
 
 
-export default class Provider extends React.Component {
+export default class UppyRNProvider extends React.Component {
   constructor () {
   constructor () {
     super()
     super()
 
 
@@ -41,13 +45,12 @@ export default class Provider extends React.Component {
 
 
   componentDidMount () {
   componentDidMount () {
     this.uppy = this.props.uppy
     this.uppy = this.props.uppy
-    // console.log('123', this.uppy)
-    this.plugin = new Instagram(this.uppy, {
-      serverUrl: 'http://localhost:3020'
+    this.uppy.use(Instagram, {
+      serverUrl: 'http://localhost:3020',
+      storage: AsyncStorage
     })
     })
-    // this.authUrl = 'http://localhost:3020'
+    this.plugin = this.uppy.getPlugin('Instagram')
     this.setState({
     this.setState({
-      // authUrl: 'http://localhost:3020'
       authUrl: this.plugin.provider.authUrl()
       authUrl: this.plugin.provider.authUrl()
     })
     })
   }
   }
@@ -69,23 +72,28 @@ export default class Provider extends React.Component {
   //   )
   //   )
   // }
   // }
 
 
-  render () {
+  renderInstagram () {
     console.log(this.state.authUrl)
     console.log(this.state.authUrl)
     return <WebView
     return <WebView
       source={{ uri: this.state.authUrl }}
       source={{ uri: this.state.authUrl }}
-      style={{marginTop: 20}}
+      style={{ marginTop: 20 }}
       onNavigationStateChange={(ev) => {
       onNavigationStateChange={(ev) => {
         const url = ev.url
         const url = ev.url
         const token = getQueryParamValueFromUrl('uppyAuthToken', url)
         const token = getQueryParamValueFromUrl('uppyAuthToken', url)
         console.log(token)
         console.log(token)
-        // this.plugin.provider.setAuthToken(token)
-        // console.log(this.plugin.provider.list())
+        this.plugin.provider.setAuthToken(token)
+        console.log(this.plugin.provider.list('recent'))
+        // return this.renderGrid(this.state.instagram.items)
       }}
       }}
     />
     />
-    // plugin.provider.setAuthToken('')
-    // plugin.provider.list()
+  }
+
+  render () {
+    if (this.props.id === 'Url') {
+      return <Url uppy={this.props.uppy} />
+    }
 
 
-    // return this.renderGrid(this.state.instagram.items)
+    return this.renderInstagram()
   }
   }
 }
 }