proxy-based Twister client written with react-js
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

55 lines
1.7 KiB

var React = require('react');
var MiniProfile = require("../common/MiniProfile.js");
var Postboard = require("../common/Postboard.js");
var SetIntervalMixin = require("../common/SetIntervalMixin.js");
var StreamMixin = require("../common/StreamMixin.js");
var SafeStateChangeMixin = require('../common/SafeStateChangeMixin.js');
var EventListenerMixin = require('../common/EventListenerMixin.js');
var AppSettingsMixin = require('../common/AppSettingsMixin.js');
module.exports = Mentions = React.createClass({displayName: "Mentions",
mixins: [StreamMixin,AppSettingsMixin,SetIntervalMixin,SafeStateChangeMixin],
contextTypes: {
router: React.PropTypes.func
},
getInitialState: function() {
return {
username: (this.context.router.getCurrentParams().username ? this.context.router.getCurrentParams().username : this.props.activeAccount),
data: [],
postIdentifiers: {},
loading: true
};
},
updateMentions: function(outdatedLimit) {
thisComponent=this;
if (outdatedLimit===undefined) {outdatedLimit=this.state.appSettings.pollInterval/2;}
Twister.getUser(this.state.username).doMentions(function(mentions){
for(var i in mentions){
thisComponent.addPost(mentions[i]);
}
thisComponent.setStateSafe({loading: false});
},{outdatedLimit: outdatedLimit});
},
componentDidMount: function() {
this.updateMentions(this.state.appSettings.pollInterval*2);
this.setInterval(this.updateMentions, this.state.appSettings.pollInterval*1000);
},
render: function() {
return (
React.createElement(Postboard, {data: this.state.data, loading: this.state.loading})
);
}
});