Skip to content

Commit

Permalink
Offline mode: enable for Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
addyosmani committed May 9, 2016
1 parent fbaea43 commit e0a2eda
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Comment.js
Expand Up @@ -3,6 +3,7 @@ var ReactFireMixin = require('reactfire')

var CommentThreadStore = require('./stores/CommentThreadStore')
var HNService = require('./services/HNService')
var HNServiceRest = require('./services/HNServiceRest')
var SettingsStore = require('./stores/SettingsStore')

var CommentMixin = require('./mixins/CommentMixin')
Expand Down Expand Up @@ -86,7 +87,17 @@ var Comment = React.createClass({
},

bindFirebaseRef() {
this.bindAsObject(HNService.itemRef(this.props.id), 'comment', this.handleFirebaseRefCancelled)
if (SettingsStore.offlineMode) {
HNServiceRest.itemRef(this.props.id).then(function(res) {
return res.json()
}).then(function(snapshot) {
this.replaceState({ comment: snapshot })
}.bind(this))
}
else {
this.bindAsObject(HNService.itemRef(this.props.id), 'comment', this.handleFirebaseRefCancelled)
}

if (this.timeout) {
this.timeout = null
}
Expand Down

0 comments on commit e0a2eda

Please sign in to comment.