minor cleanup, support for delayed topic creation

This commit is contained in:
or-else
2022-03-07 19:41:17 -08:00
parent 9c2d3f3693
commit 42ae953055
10 changed files with 44 additions and 42 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
{ {
"name": "tinode-webapp", "name": "tinode-webapp",
"description": "Tinode messenger for the web", "description": "Tinode messenger for the web",
"version": "0.18.3-beta1", "version": "0.19.0-alpha1",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -71,7 +71,7 @@
"react": "^17.0.2", "react": "^17.0.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-intl": "^5.20.2", "react-intl": "^5.20.2",
"tinode-sdk": "^0.18.2" "tinode-sdk": "^0.19.0-alpha1"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.14.5", "@babel/core": "^7.14.5",
+1 -1
View File
@@ -1,3 +1,3 @@
// This is a generated file. Don't edit. // This is a generated file. Don't edit.
export const PACKAGE_VERSION = "0.18.3-beta1"; export const PACKAGE_VERSION = "0.19.0-alpha1";
+9 -2
View File
@@ -1,3 +1,5 @@
// Panel with a chat.
import React from 'react'; import React from 'react';
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
@@ -185,10 +187,15 @@ class MessagesView extends React.Component {
this.postReadNotification(0); this.postReadNotification(0);
} }
if ((this.state.topic != prevState.topic) || !prevProps.ready) { if (topic && ((this.state.topic != prevState.topic) || !prevProps.ready)) {
if (topic._new) {
console.log('Fetching new topic description');
topic.getMeta(topic.startMetaQuery().withDesc().build());
} else {
this.subscribe(topic); this.subscribe(topic);
} }
} }
}
static getDerivedStateFromProps(nextProps, prevState) { static getDerivedStateFromProps(nextProps, prevState) {
let nextState = {}; let nextState = {};
@@ -340,7 +347,7 @@ class MessagesView extends React.Component {
} }
subscribe(topic) { subscribe(topic) {
if (!topic || topic.isSubscribed() || !this.props.ready) { if (topic.isSubscribed() || !this.props.ready) {
return; return;
} }
+4 -4
View File
@@ -41,7 +41,7 @@ class NewTopicView extends React.Component {
this.handleTabClick = this.handleTabClick.bind(this); this.handleTabClick = this.handleTabClick.bind(this);
this.handleSearchContacts = this.handleSearchContacts.bind(this); this.handleSearchContacts = this.handleSearchContacts.bind(this);
this.handleContactSelected = this.handleContactSelected.bind(this); this.handleSearchResultSelected = this.handleSearchResultSelected.bind(this);
this.handleNewGroupSubmit = this.handleNewGroupSubmit.bind(this); this.handleNewGroupSubmit = this.handleNewGroupSubmit.bind(this);
this.handleGroupByID = this.handleGroupByID.bind(this); this.handleGroupByID = this.handleGroupByID.bind(this);
} }
@@ -61,10 +61,10 @@ class NewTopicView extends React.Component {
this.setState({searchQuery: Tinode.isNullValue(query) ? null : query}); this.setState({searchQuery: Tinode.isNullValue(query) ? null : query});
} }
handleContactSelected(uid) { handleSearchResultSelected(name) {
if (this.state.tabSelected == 'find') { if (this.state.tabSelected == 'find') {
HashNavigation.navigateTo(HashNavigation.removeUrlParam(window.location.hash, 'tab')); HashNavigation.navigateTo(HashNavigation.removeUrlParam(window.location.hash, 'tab'));
this.props.onCreateTopic(uid); this.props.onCreateTopic(name);
} }
} }
@@ -126,7 +126,7 @@ class NewTopicView extends React.Component {
showOnline={false} showOnline={false}
showUnread={false} showUnread={false}
showContextMenu={false} showContextMenu={false}
onTopicSelected={this.handleContactSelected} /> onTopicSelected={this.handleSearchResultSelected} />
</div>} </div>}
</div> </div>
); );
+6 -10
View File
@@ -460,14 +460,10 @@ class TinodeWeb extends React.Component {
// Clear invalid topic name. // Clear invalid topic name.
topicName = null; topicName = null;
} }
const newState = { this.setState({
topicSelected: topicName topicSelected: topicName,
}; topicSelectedAcs: this.tinode.getTopicAccessMode(topicName)
const acs = this.tinode.getTopicAccessMode(topicName); });
if (acs) {
newState.topicSelectedAcs = acs;
}
this.setState(newState);
} }
} else { } else {
// Empty hashpath // Empty hashpath
@@ -911,7 +907,7 @@ class TinodeWeb extends React.Component {
}); });
} }
// User clicked on a contact in the side panel or deleted a contact. // User clicked on a topic in the side panel or deleted a topic.
handleTopicSelected(topicName) { handleTopicSelected(topicName) {
// Clear newTopicParams after use. // Clear newTopicParams after use.
if (this.state.newTopicParams && this.state.newTopicParams._topicName != topicName) { if (this.state.newTopicParams && this.state.newTopicParams._topicName != topicName) {
@@ -927,7 +923,7 @@ class TinodeWeb extends React.Component {
mobilePanel: 'topic-view', mobilePanel: 'topic-view',
infoPanel: undefined infoPanel: undefined
}); });
// Different contact selected. // Different topic selected.
if (this.state.topicSelected != topicName) { if (this.state.topicSelected != topicName) {
this.setState({ this.setState({
topicSelectedOnline: this.tinode.isTopicOnline(topicName), topicSelectedOnline: this.tinode.isTopicOnline(topicName),
+16 -17
View File
@@ -3334,7 +3334,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "PACKAGE_VERSION": () => (/* binding */ PACKAGE_VERSION) /* harmony export */ "PACKAGE_VERSION": () => (/* binding */ PACKAGE_VERSION)
/* harmony export */ }); /* harmony export */ });
const PACKAGE_VERSION = "0.18.3-beta1"; const PACKAGE_VERSION = "0.19.0-alpha1";
/***/ }), /***/ }),
@@ -5482,10 +5482,15 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
this.postReadNotification(0); this.postReadNotification(0);
} }
if (this.state.topic != prevState.topic || !prevProps.ready) { if (topic && (this.state.topic != prevState.topic || !prevProps.ready)) {
if (topic._new) {
console.log('Fetching new topic description');
topic.getMeta(topic.startMetaQuery().withDesc().build());
} else {
this.subscribe(topic); this.subscribe(topic);
} }
} }
}
static getDerivedStateFromProps(nextProps, prevState) { static getDerivedStateFromProps(nextProps, prevState) {
let nextState = {}; let nextState = {};
@@ -5641,7 +5646,7 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
} }
subscribe(topic) { subscribe(topic) {
if (!topic || topic.isSubscribed() || !this.props.ready) { if (topic.isSubscribed() || !this.props.ready) {
return; return;
} }
@@ -6609,7 +6614,7 @@ class NewTopicView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
}; };
this.handleTabClick = this.handleTabClick.bind(this); this.handleTabClick = this.handleTabClick.bind(this);
this.handleSearchContacts = this.handleSearchContacts.bind(this); this.handleSearchContacts = this.handleSearchContacts.bind(this);
this.handleContactSelected = this.handleContactSelected.bind(this); this.handleSearchResultSelected = this.handleSearchResultSelected.bind(this);
this.handleNewGroupSubmit = this.handleNewGroupSubmit.bind(this); this.handleNewGroupSubmit = this.handleNewGroupSubmit.bind(this);
this.handleGroupByID = this.handleGroupByID.bind(this); this.handleGroupByID = this.handleGroupByID.bind(this);
} }
@@ -6633,10 +6638,10 @@ class NewTopicView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
}); });
} }
handleContactSelected(uid) { handleSearchResultSelected(name) {
if (this.state.tabSelected == 'find') { if (this.state.tabSelected == 'find') {
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_7__["default"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_7__["default"].removeUrlParam(window.location.hash, 'tab')); _lib_navigation_js__WEBPACK_IMPORTED_MODULE_7__["default"].navigateTo(_lib_navigation_js__WEBPACK_IMPORTED_MODULE_7__["default"].removeUrlParam(window.location.hash, 'tab'));
this.props.onCreateTopic(uid); this.props.onCreateTopic(name);
} }
} }
@@ -6719,7 +6724,7 @@ class NewTopicView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
showOnline: false, showOnline: false,
showUnread: false, showUnread: false,
showContextMenu: false, showContextMenu: false,
onTopicSelected: this.handleContactSelected onTopicSelected: this.handleSearchResultSelected
}))); })));
} }
@@ -7814,16 +7819,10 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
topicName = null; topicName = null;
} }
const newState = { this.setState({
topicSelected: topicName topicSelected: topicName,
}; topicSelectedAcs: this.tinode.getTopicAccessMode(topicName)
const acs = this.tinode.getTopicAccessMode(topicName); });
if (acs) {
newState.topicSelectedAcs = acs;
}
this.setState(newState);
} }
} else { } else {
this.setState({ this.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
+1 -1
View File
@@ -1,3 +1,3 @@
// This is a generated file. Don't edit. // This is a generated file. Don't edit.
const PACKAGE_VERSION = "0.18.3-beta1"; const PACKAGE_VERSION = "0.19.0-alpha1";