Skip to content

Commit 83ebc1b

Browse files
committed
Offline mode: enable for permalink comments
1 parent 995b30f commit 83ebc1b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/PermalinkedComment.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var withRouter = require('react-router/lib/withRouter')
44

55
var CommentThreadStore = require('./stores/CommentThreadStore')
66
var HNService = require('./services/HNService')
7+
var HNServiceRest = require('./services/HNServiceRest')
78
var SettingsStore = require('./stores/SettingsStore')
89
var UpdatesStore = require('./stores/UpdatesStore')
910

@@ -32,7 +33,16 @@ var PermalinkedComment = React.createClass({
3233
},
3334

3435
componentWillMount() {
35-
this.bindAsObject(HNService.itemRef(this.props.params.id), 'comment')
36+
if (SettingsStore.offlineMode) {
37+
HNServiceRest.itemRef(this.props.params.id).then(function(res) {
38+
return res.json()
39+
}).then(function(snapshot) {
40+
this.replaceState({ comment: snapshot })
41+
}.bind(this))
42+
}
43+
else {
44+
this.bindAsObject(HNService.itemRef(this.props.params.id), 'comment')
45+
}
3646
if (this.state.comment.id) {
3747
this.commentLoaded(this.state.comment)
3848
}

0 commit comments

Comments
 (0)