Browse Source

fixed app slug + fixed app reopening

Skylsmoi 6 years ago
parent
commit
1c7a2c309a
1 changed files with 7 additions and 5 deletions
  1. 7 5
      src/container/Thread.jsx

+ 7 - 5
src/container/Thread.jsx View File

36
     document.addEventListener('appCustomEvent', this.customEventReducer)
36
     document.addEventListener('appCustomEvent', this.customEventReducer)
37
   }
37
   }
38
 
38
 
39
-  customEventReducer = ({ detail: action }) => { // action: { type: '', data: {} }
40
-    switch (action.type) {
41
-      case 'Thread_showApp':
39
+  customEventReducer = ({ detail: { type, data } }) => { // action: { type: '', data: {} }
40
+    switch (type) {
41
+      case 'thread_showApp':
42
         this.setState({isVisible: true})
42
         this.setState({isVisible: true})
43
         break
43
         break
44
-      case 'Thread_hideApp':
44
+      case 'thread_hideApp':
45
         this.setState({isVisible: false})
45
         this.setState({isVisible: false})
46
         break
46
         break
47
+      case 'thread_reloadContent':
48
+        this.setState(prev => ({content: {...prev.content, ...data}, isVisible: true}))
47
     }
49
     }
48
   }
50
   }
49
 
51
 
135
 
137
 
136
     handleFetchResult(await fetchResultSaveEditStatus)
138
     handleFetchResult(await fetchResultSaveEditStatus)
137
       .then(resSave => {
139
       .then(resSave => {
138
-        if (resSave.apiResponse.status !== 204) { // 204 no content so dont take status from resSave.apiResponse.status
140
+        if (resSave.status !== 204) { // 204 no content so dont take status from resSave.apiResponse.status
139
           console.warn('Error saving thread comment. Result:', resSave, 'content:', content, 'config:', config)
141
           console.warn('Error saving thread comment. Result:', resSave, 'content:', content, 'config:', config)
140
         } else {
142
         } else {
141
           this.loadContent()
143
           this.loadContent()