Procházet zdrojové kódy

Update ImageList.js

AY před 4 roky
rodič
revize
4928b8025a
1 změnil soubory, kde provedl 9 přidání a 6 odebrání
  1. 9 6
      photo/src/ImageList.js

+ 9 - 6
photo/src/ImageList.js

@@ -35,13 +35,12 @@ class imageList extends React.Component {
         super(props);
 
         this.state = {
-            images: this.props.images,
+            images: [],
             currentImage: 0,
             currentImagePath: "",
 
             error: null,
             isLoaded: false,
-            items: [],
 
             open: false,
             //for modal
@@ -62,6 +61,7 @@ class imageList extends React.Component {
 
     shareImage() {
         this.setState({ open: true, currentImagePath: this.state.images[this.state.currentImage].src });
+        console.log(this.state.currentImagePath)
         fetch("/backend_test/share?path=" + this.state.currentImagePath, {})
             .then(res => res.json())
             .then(
@@ -89,9 +89,12 @@ class imageList extends React.Component {
     }
 */
     handleChange(event) {
-        if (!(event.target.value == "remove")) {
+        var uuid = this.state.uuid;
+        var mode = event.target.value;
+        var path = this.state.currentImagePath;
+        if (event.target.value != "remove") {
             //this.setState({ currency: event.target.value });
-            fetch('/backend_test/edit?uuid=' + this.state.uuid + '&mode=' + event.target.value, {
+            fetch('/backend_test/edit?uuid=' + uuid + '&mode=' + mode, {
                 method: 'GET',
                 headers: {
                     'Content-Type': 'application/json'
@@ -101,7 +104,7 @@ class imageList extends React.Component {
                 .then((data) => data);
         } else {
             //remove but use edit response now
-            fetch("/backend_test/remove?path=" + this.state.currentImagePath, {
+            fetch("/backend_test/remove?path=" + path, {
                 method: 'GET',
                 headers: {
                     'Content-Type': 'application/json'
@@ -152,7 +155,7 @@ class imageList extends React.Component {
 
     render() {
         const { classes } = this.props;
-        const { isLoaded, items, error } = this.state;
+        const { isLoaded, error } = this.state;
         const theme = {
             margin: 4,
         }