@@ -52,16 +52,18 @@ var Comment = React.createClass({
5252 return
5353 }
5454
55- if ( ! prevState . comment . id ) {
55+ // On !prevState.comment: a comment which was initially null - see
56+ // above - may eventually load when the API catches up.
57+ if ( ! prevState . comment || ! prevState . comment . id ) {
5658 // Register a newly-loaded comment with the thread store
5759 if ( this . state . comment . id ) {
58- // If the commant was delayed, cancel any pending timeout
59- if ( prevState . comment . delayed ) {
60+ // If the comment was delayed, cancel any pending timeout
61+ if ( prevState . comment && prevState . comment . delayed ) {
6062 this . clearDelayTimeout ( )
6163 }
6264 this . props . threadStore . commentAdded ( this . state . comment )
6365 }
64- if ( ! prevState . comment . delayed && this . state . comment . delayed ) {
66+ if ( prevState . comment && ! prevState . comment . delayed && this . state . comment . delayed ) {
6567 this . props . threadStore . commentDelayed ( this . props . id )
6668 }
6769 }
@@ -94,16 +96,16 @@ var Comment = React.createClass({
9496
9597 /**
9698 * This is usually caused by a permissions error loading the comment due to
97- * its author using the delay setting, which is measured in minutes - try
98- * again in 30 seconds.
99+ * its author using the delay setting (note: this is conjecture), which is
100+ * measured in minutes - try again in 30 seconds.
99101 */
100102 handleFirebaseRefCancelled ( e ) {
101103 if ( "production" !== process . env . NODE_ENV ) {
102104 console . error ( 'Firebase ref for comment ' + this . props . id + ' was cancelled: ' + e . message )
103105 }
104106 this . unbind ( 'comment' )
105107 this . timeout = setTimeout ( this . bindFirebaseRef , 30000 )
106- if ( ! this . state . comment . delayed ) {
108+ if ( this . state . comment && ! this . state . comment . delayed ) {
107109 this . state . comment . delayed = true
108110 this . forceUpdate ( )
109111 }
0 commit comments