@@ -84,6 +84,17 @@ export default class Ticket extends Component {
8484 }
8585 }
8686
87+ refreshTicket ( ) {
88+ const { ticket } = this . state
89+ if ( ! ticket ) return
90+ return ticket . fetch ( {
91+ include : [ 'author' , 'assignee' , 'files' ]
92+ } ) . then ( ( ) => {
93+ this . setState ( { ticket} )
94+ return ticket
95+ } )
96+ }
97+
8798 getReplyQuery ( ticket ) {
8899 const replyQuery = new AV . Query ( 'Reply' )
89100 . equalTo ( 'ticket' , ticket )
@@ -93,12 +104,12 @@ export default class Ticket extends Component {
93104 replyQuery . subscribe ( { subscriptionId : UUID + '@' + ticket . id } ) . then ( liveQuery => {
94105 this . replyLiveQuery = liveQuery
95106 this . replyLiveQuery . on ( 'create' , reply => {
96- return reply . fetch ( { include : 'ticket, author,files' } )
107+ return reply . fetch ( { include : 'author,files' } )
97108 . then ( ( ) => {
98109 const replies = this . state . replies
99110 replies . push ( reply )
100- this . setState ( { ticket : reply . get ( 'ticket' ) , replies} )
101- return
111+ this . setState ( { replies} )
112+ return this . refreshTicket ( )
102113 } ) . catch ( this . context . addNotification )
103114 } )
104115 return
@@ -115,12 +126,12 @@ export default class Ticket extends Component {
115126 . then ( liveQuery => {
116127 this . opsLogLiveQuery = liveQuery
117128 this . opsLogLiveQuery . on ( 'create' , opsLog => {
118- return opsLog . fetch ( { include : 'ticket' } )
129+ return opsLog . fetch ( )
119130 . then ( ( ) => {
120131 const opsLogs = this . state . opsLogs
121132 opsLogs . push ( opsLog )
122- this . setState ( { ticket : opsLog . get ( 'ticket' ) , opsLogs} )
123- return
133+ this . setState ( { opsLogs} )
134+ return this . refreshTicket ( )
124135 } ) . catch ( this . context . addNotification )
125136 } )
126137 return
0 commit comments