@@ -5,7 +5,7 @@ import { Icon, Segment, Button } from 'semantic-ui-react';
5
5
import { toast } from 'react-semantic-toasts' ;
6
6
7
7
import { jsonHeaders } from '../../constants/formPostRequestHeaders'
8
- import { urlCmsIntegration , urlIITRMain , urlCms } from '../../urls' ;
8
+ import { urlCmsIntegration , urlWebSocketServer } from '../../urls' ;
9
9
10
10
import style from '../../styles.css' ;
11
11
@@ -20,10 +20,22 @@ class CMSIntegration extends React.PureComponent {
20
20
publish : false
21
21
}
22
22
}
23
+ this . streamSocket = new WebSocket ( urlWebSocketServer ( ) ) ;
24
+ }
25
+ componentDidMount ( ) {
26
+ this . streamSocket . onmessage = ( e ) => {
27
+ const data = JSON . parse ( e . data )
28
+ this . setState ( {
29
+ loading : {
30
+ ...this . state . loading ,
31
+ publish : ! ( data . published === 'published' ) ,
32
+ }
33
+ } )
34
+ }
23
35
}
24
36
onPreview = ( ) => {
25
37
this . setState ( {
26
- loading :{
38
+ loading : {
27
39
... this . state . loading ,
28
40
preview : true
29
41
}
@@ -80,7 +92,7 @@ class CMSIntegration extends React.PureComponent {
80
92
81
93
onPublish = ( ) => {
82
94
this . setState ( {
83
- loading :{
95
+ loading : {
84
96
... this . state . loading ,
85
97
publish : true
86
98
}
@@ -120,6 +132,12 @@ class CMSIntegration extends React.PureComponent {
120
132
Try previewing your page after some time!
121
133
</ p >
122
134
)
135
+ this . setState ( {
136
+ loading :{
137
+ ... this . state . loading ,
138
+ publish : false
139
+ }
140
+ } ) ;
123
141
toast ( {
124
142
type : 'error' ,
125
143
title : 'Publish Error' ,
@@ -129,21 +147,13 @@ class CMSIntegration extends React.PureComponent {
129
147
} ) ;
130
148
return 'error' ;
131
149
} )
132
- . finally ( code => {
133
- this . setState ( {
134
- loading :{
135
- ... this . state . loading ,
136
- publish : false
137
- }
138
- } ) ;
139
- } ) ;
140
150
}
141
151
142
152
render ( ) {
143
153
const { theme } = this . props ;
144
154
const previewLoad = this . state . loading . preview ;
145
155
const publishLoad = this . state . loading . publish ;
146
- return (
156
+ return (
147
157
< div >
148
158
< BrowserView >
149
159
< Segment
0 commit comments