crash on missing topic parameters, ranamed var for clarity

This commit is contained in:
or-else
2022-01-28 10:17:14 -08:00
parent 41bf6f3941
commit 728b3a3a1b
9 changed files with 706 additions and 471 deletions
+4 -5
View File
@@ -35,7 +35,7 @@ class NewTopicView extends React.Component {
super(props); super(props);
this.state = { this.state = {
tabSelected: 'p2p', tabSelected: 'find',
searchQuery: null searchQuery: null
}; };
@@ -62,7 +62,7 @@ class NewTopicView extends React.Component {
} }
handleContactSelected(uid) { handleContactSelected(uid) {
if (this.state.tabSelected == 'p2p') { 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(uid);
} }
@@ -87,8 +87,8 @@ class NewTopicView extends React.Component {
return ( return (
<div className="flex-column"> <div className="flex-column">
<ul className="tabbar"> <ul className="tabbar">
<li className={this.state.tabSelected === "p2p" ? "active" : null}> <li className={this.state.tabSelected === "find" ? "active" : null}>
<a href="#" data-id="p2p" onClick={this.handleTabClick}> <a href="#" data-id="find" onClick={this.handleTabClick}>
<FormattedMessage id="tabtitle_find_user" defaultMessage="find" <FormattedMessage id="tabtitle_find_user" defaultMessage="find"
description="Tab title Find" /> description="Tab title Find" />
</a> </a>
@@ -116,7 +116,6 @@ class NewTopicView extends React.Component {
onError={this.props.onError} /> : onError={this.props.onError} /> :
<div className="flex-column"> <div className="flex-column">
<SearchContacts <SearchContacts
type="p2p"
placeholder={search_placeholder} placeholder={search_placeholder}
onSearchContacts={this.handleSearchContacts} /> onSearchContacts={this.handleSearchContacts} />
<ContactList <ContactList
+4 -2
View File
@@ -1235,8 +1235,10 @@ class TinodeWeb extends React.Component {
params.desc = {defacs: {auth: DEFAULT_P2P_ACCESS_MODE}}; params.desc = {defacs: {auth: DEFAULT_P2P_ACCESS_MODE}};
} else { } else {
topicName = topicName || this.tinode.newGroupTopicName(isChannel); topicName = topicName || this.tinode.newGroupTopicName(isChannel);
params.desc = {public: newTopicParams.public, private: {comment: newTopicParams.private}}; if (newTopicParams) {
params.tags = newTopicParams.tags; params.desc = {public: newTopicParams.public, private: {comment: newTopicParams.private}};
params.tags = newTopicParams.tags;
}
} }
params._topicName = topicName; params._topicName = topicName;
this.setState({newTopicParams: params}, () => {this.handleTopicSelected(topicName)}); this.setState({newTopicParams: params}, () => {this.handleTopicSelected(topicName)});
-1
View File
@@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import { FormattedMessage } from 'react-intl';
import Tinode from 'tinode-sdk'; import Tinode from 'tinode-sdk';
+19 -20
View File
@@ -4568,7 +4568,7 @@ class NewTopicView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
tabSelected: 'p2p', tabSelected: 'find',
searchQuery: null searchQuery: null
}; };
this.handleTabClick = this.handleTabClick.bind(this); this.handleTabClick = this.handleTabClick.bind(this);
@@ -4598,7 +4598,7 @@ class NewTopicView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
} }
handleContactSelected(uid) { handleContactSelected(uid) {
if (this.state.tabSelected == 'p2p') { 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(uid);
} }
@@ -4629,10 +4629,10 @@ class NewTopicView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
}, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", { }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("ul", {
className: "tabbar" className: "tabbar"
}, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", { }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", {
className: this.state.tabSelected === "p2p" ? "active" : null className: this.state.tabSelected === "find" ? "active" : null
}, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", { }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement("a", {
href: "#", href: "#",
"data-id": "p2p", "data-id": "find",
onClick: this.handleTabClick onClick: this.handleTabClick
}, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__.FormattedMessage, { }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react_intl__WEBPACK_IMPORTED_MODULE_1__.FormattedMessage, {
id: "tabtitle_find_user", id: "tabtitle_find_user",
@@ -4673,7 +4673,6 @@ class NewTopicView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
}) : react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", { }) : react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
className: "flex-column" className: "flex-column"
}, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_widgets_search_contacts_jsx__WEBPACK_IMPORTED_MODULE_6__["default"], { }, react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_widgets_search_contacts_jsx__WEBPACK_IMPORTED_MODULE_6__["default"], {
type: "p2p",
placeholder: search_placeholder, placeholder: search_placeholder,
onSearchContacts: this.handleSearchContacts onSearchContacts: this.handleSearchContacts
}), react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_widgets_contact_list_jsx__WEBPACK_IMPORTED_MODULE_3__["default"], { }), react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_widgets_contact_list_jsx__WEBPACK_IMPORTED_MODULE_3__["default"], {
@@ -6577,13 +6576,16 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
}; };
} else { } else {
topicName = topicName || this.tinode.newGroupTopicName(isChannel); topicName = topicName || this.tinode.newGroupTopicName(isChannel);
params.desc = {
public: newTopicParams.public, if (newTopicParams) {
private: { params.desc = {
comment: newTopicParams.private public: newTopicParams.public,
} private: {
}; comment: newTopicParams.private
params.tags = newTopicParams.tags; }
};
params.tags = newTopicParams.tags;
}
} }
params._topicName = topicName; params._topicName = topicName;
@@ -11599,11 +11601,8 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ }); /* harmony export */ });
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react"); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react-intl */ "react-intl"); /* harmony import */ var tinode_sdk__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tinode-sdk */ "tinode-sdk");
/* harmony import */ var react_intl__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_intl__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var tinode_sdk__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(tinode_sdk__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var tinode_sdk__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tinode-sdk */ "tinode-sdk");
/* harmony import */ var tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(tinode_sdk__WEBPACK_IMPORTED_MODULE_2__);
class SearchContacts extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComponent) { class SearchContacts extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureComponent) {
@@ -11625,7 +11624,7 @@ class SearchContacts extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureC
search: '', search: '',
edited: false edited: false
}); });
this.props.onSearchContacts((tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default().DEL_CHAR)); this.props.onSearchContacts((tinode_sdk__WEBPACK_IMPORTED_MODULE_1___default().DEL_CHAR));
} }
} }
@@ -11641,14 +11640,14 @@ class SearchContacts extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureC
this.setState({ this.setState({
edited: query.length > 0 edited: query.length > 0
}); });
this.props.onSearchContacts(query.length > 0 ? query : (tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default().DEL_CHAR)); this.props.onSearchContacts(query.length > 0 ? query : (tinode_sdk__WEBPACK_IMPORTED_MODULE_1___default().DEL_CHAR));
} }
handleClear(e) { handleClear(e) {
e.preventDefault(); e.preventDefault();
if (this.state.edited) { if (this.state.edited) {
this.props.onSearchContacts((tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default().DEL_CHAR)); this.props.onSearchContacts((tinode_sdk__WEBPACK_IMPORTED_MODULE_1___default().DEL_CHAR));
} }
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
+675 -439
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