request messages when subscribing to a new topic

This commit is contained in:
or-else
2019-04-08 16:11:43 +03:00
parent 4b561de04c
commit e73c41f3c6
5 changed files with 22 additions and 11 deletions
+10 -5
View File
@@ -122,17 +122,22 @@ class MessagesView extends React.Component {
if (topic && !topic.isSubscribed() && this.props.ready &&
((this.state.topic != prevState.topic) || !prevProps.ready)) {
// Is this a new topic?
const newTopic = (this.props.newTopicParams && this.props.newTopicParams._topicName == this.props.topic);
// Don't request the tags. They are useless unless the user
// is the owner and is editing the topic.
let getQuery = topic.startMetaQuery().withLaterDesc().withLaterSub();
if (this.state.isReader) {
// If reading is permitted, ask for messages.
getQuery = getQuery.withLaterData(MESSAGES_PAGE).withLaterDel();
if (this.state.isReader || newTopic) {
// If reading is either permitted or we don't know because it's a new topic. Ask for messages.
getQuery = getQuery.withLaterData(MESSAGES_PAGE);
if (this.state.isReader) {
getQuery = getQuery.withLaterDel();
}
// And show "loading" spinner.
this.setState({ fetchingMessages: true });
}
const setQuery = (this.props.newTopicParams && this.props.newTopicParams._topicName == this.props.topic) ?
this.props.newTopicParams : undefined;
const setQuery = newTopic ? this.props.newTopicParams : undefined;
topic.subscribe(getQuery.build(), setQuery)
.then((ctrl) => {
if (this.state.topic != ctrl.topic) {
+9 -3
View File
@@ -2716,16 +2716,22 @@ var MessagesView = function (_React$Component) {
}
if (topic && !topic.isSubscribed() && this.props.ready && (this.state.topic != prevState.topic || !prevProps.ready)) {
var newTopic = this.props.newTopicParams && this.props.newTopicParams._topicName == this.props.topic;
var getQuery = topic.startMetaQuery().withLaterDesc().withLaterSub();
if (this.state.isReader) {
getQuery = getQuery.withLaterData(_config_js__WEBPACK_IMPORTED_MODULE_12__["MESSAGES_PAGE"]).withLaterDel();
if (this.state.isReader || newTopic) {
getQuery = getQuery.withLaterData(_config_js__WEBPACK_IMPORTED_MODULE_12__["MESSAGES_PAGE"]);
if (this.state.isReader) {
getQuery = getQuery.withLaterDel();
}
this.setState({
fetchingMessages: true
});
}
var setQuery = this.props.newTopicParams && this.props.newTopicParams._topicName == this.props.topic ? this.props.newTopicParams : undefined;
var setQuery = newTopic ? this.props.newTopicParams : undefined;
topic.subscribe(getQuery.build(), setQuery).then(function (ctrl) {
if (_this2.state.topic != ctrl.topic) {
_this2.setState({
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long