change method signatures to make TopicCommonView usable in INfoView
This commit is contained in:
@@ -46,7 +46,7 @@ class AccSecurityView extends React.Component {
|
||||
|
||||
handlePasswordUpdate(pwd) {
|
||||
this.setState({password: pwd});
|
||||
this.props.onUpdateAccount(pwd);
|
||||
this.props.onUpdatePassword(pwd);
|
||||
}
|
||||
|
||||
handleLaunchPermissionsEditor(which) {
|
||||
@@ -63,7 +63,7 @@ class AccSecurityView extends React.Component {
|
||||
handlePermissionsChanged(perm) {
|
||||
let defacs = {};
|
||||
defacs[this.state.showPermissionEditorFor] = perm;
|
||||
this.props.onUpdateAccount(undefined, undefined, defacs);
|
||||
this.props.onUpdateAccountDesc('me', undefined, undefined, defacs);
|
||||
|
||||
let newState = {showPermissionEditorFor: undefined};
|
||||
newState[this.state.showPermissionEditorFor] = perm;
|
||||
|
||||
@@ -181,7 +181,7 @@ class SidepanelView extends React.Component {
|
||||
tinode={this.props.tinode}
|
||||
myUserId={this.props.myUserId}
|
||||
onBasicNavigate={this.props.onBasicNavigate}
|
||||
onUpdateAccount={this.props.onUpdateAccount}
|
||||
onUpdateTopicDesc={this.props.onUpdateAccountDesc}
|
||||
onUpdateTags={this.props.onUpdateAccountTags}
|
||||
onCredAdd={this.props.onCredAdd}
|
||||
onCredDelete={this.props.onCredDelete}
|
||||
@@ -201,7 +201,8 @@ class SidepanelView extends React.Component {
|
||||
view === 'security' ?
|
||||
<AccSecurityView
|
||||
tinode={this.props.tinode}
|
||||
onUpdateAccount={this.props.onUpdateAccount}
|
||||
onUpdateAccountDesc={this.props.onUpdateAccountDesc}
|
||||
onUpdatePassword={this.props.onUpdatePassword}
|
||||
onLogout={this.props.onLogout}
|
||||
onDeleteAccount={this.props.onDeleteAccount}
|
||||
onShowAlert={this.props.onShowAlert}
|
||||
|
||||
+25
-33
@@ -1,6 +1,5 @@
|
||||
// The top-level class to hold all functionality together.
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import * as firebase from 'firebase/app';
|
||||
@@ -70,6 +69,8 @@ class TinodeWeb extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.selfRef = React.createRef();
|
||||
|
||||
this.state = this.getBlankState();
|
||||
|
||||
this.handleResize = this.handleResize.bind(this);
|
||||
@@ -100,7 +101,7 @@ class TinodeWeb extends React.Component {
|
||||
this.handleNewChatInvitation = this.handleNewChatInvitation.bind(this);
|
||||
this.handleNewAccount = this.handleNewAccount.bind(this);
|
||||
this.handleNewAccountRequest = this.handleNewAccountRequest.bind(this);
|
||||
this.handleUpdateAccountRequest = this.handleUpdateAccountRequest.bind(this);
|
||||
this.handleUpdatePasswordRequest = this.handleUpdatePasswordRequest.bind(this);
|
||||
this.handleUpdateAccountTagsRequest = this.handleUpdateAccountTagsRequest.bind(this);
|
||||
this.handleToggleIncognitoMode = this.handleToggleIncognitoMode.bind(this);
|
||||
this.handleSettings = this.handleSettings.bind(this);
|
||||
@@ -980,31 +981,6 @@ class TinodeWeb extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
handleUpdateAccountRequest(password, pub, defacs) {
|
||||
this.handleError();
|
||||
|
||||
if (pub || defacs) {
|
||||
const params = {};
|
||||
if (pub) {
|
||||
params.public = pub;
|
||||
if (pub.photo && pub.photo.ref) {
|
||||
params.attachments = [pub.photo.ref];
|
||||
}
|
||||
}
|
||||
if (defacs) {
|
||||
params.defacs = defacs;
|
||||
}
|
||||
this.tinode.getMeTopic().setMeta({desc: params}).catch((err) => {
|
||||
this.handleError(err.message, 'err');
|
||||
});
|
||||
}
|
||||
if (password) {
|
||||
this.tinode.updateAccountBasic(null, this.tinode.getCurrentLogin(), password).catch((err) => {
|
||||
this.handleError(err.message, 'err');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleToggleIncognitoMode(on) {
|
||||
const me = this.tinode.getMeTopic();
|
||||
const am = me.getAccessMode().updateWant(on ? '-P' : '+P').getWant();
|
||||
@@ -1212,19 +1188,24 @@ class TinodeWeb extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
handleTopicUpdateRequest(topicName, pub, priv, permissions) {
|
||||
handleTopicUpdateRequest(topicName, pub, priv, defacs) {
|
||||
this.handleError();
|
||||
|
||||
const topic = this.tinode.getTopic(topicName);
|
||||
if (topic) {
|
||||
const params = {};
|
||||
if (pub) {
|
||||
params.public = pub;
|
||||
if (pub.photo && pub.photo.ref) {
|
||||
params.attachments = [pub.photo.ref];
|
||||
}
|
||||
}
|
||||
if (priv) {
|
||||
params.private = (priv === Tinode.DEL_CHAR) ?
|
||||
Tinode.DEL_CHAR : {comment: priv};
|
||||
}
|
||||
if (permissions) {
|
||||
params.defacs = permissions;
|
||||
if (defacs) {
|
||||
params.defacs = defacs;
|
||||
}
|
||||
topic.setMeta({desc: params}).catch((err) => {
|
||||
this.handleError(err.message, 'err');
|
||||
@@ -1232,6 +1213,16 @@ class TinodeWeb extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
handleUpdatePasswordRequest(password) {
|
||||
this.handleError();
|
||||
|
||||
if (password) {
|
||||
this.tinode.updateAccountBasic(null, this.tinode.getCurrentLogin(), password).catch((err) => {
|
||||
this.handleError(err.message, 'err');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleChangePermissions(topicName, mode, uid) {
|
||||
const topic = this.tinode.getTopic(topicName);
|
||||
if (topic) {
|
||||
@@ -1359,7 +1350,7 @@ class TinodeWeb extends React.Component {
|
||||
contextMenuClickAt: {x: params.x, y: params.y},
|
||||
contextMenuParams: params,
|
||||
contextMenuItems: menuItems || this.defaultTopicContextMenu(params.topicName),
|
||||
contextMenuBounds: ReactDOM.findDOMNode(this).getBoundingClientRect()
|
||||
contextMenuBounds: this.selfRef.getBoundingClientRect()
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1510,7 +1501,7 @@ class TinodeWeb extends React.Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div id="app-container">
|
||||
<div id="app-container" ref={this.selfRef}>
|
||||
{this.state.contextMenuVisible ?
|
||||
<ContextMenu
|
||||
tinode={this.tinode}
|
||||
@@ -1579,7 +1570,8 @@ class TinodeWeb extends React.Component {
|
||||
onLoginRequest={this.handleLoginRequest}
|
||||
onPersistenceChange={this.handlePersistenceChange}
|
||||
onCreateAccount={this.handleNewAccountRequest}
|
||||
onUpdateAccount={this.handleUpdateAccountRequest}
|
||||
onUpdateAccountDesc={this.handleTopicUpdateRequest}
|
||||
onUpdatePassword={this.handleUpdatePasswordRequest}
|
||||
onUpdateAccountTags={this.handleUpdateAccountTagsRequest}
|
||||
onTogglePushNotifications={this.togglePushToken}
|
||||
onToggleMessageSounds={this.handleToggleMessageSounds}
|
||||
|
||||
@@ -71,7 +71,7 @@ export default class TopicCommonView extends React.Component {
|
||||
fn = fn.trim().substring(0, MAX_TITLE_LENGTH);
|
||||
if (fn) {
|
||||
this.setState({fullName: fn});
|
||||
this.props.onUpdateAccount(undefined, theCard(fn, null));
|
||||
this.props.onUpdateTopicDesc(this.props.topic, theCard(fn, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export default class TopicCommonView extends React.Component {
|
||||
this.setState({newAvatar: img, newAvatarMime: mime});
|
||||
if (!img) {
|
||||
// Deleting the avatar.
|
||||
this.props.onUpdateAccount(undefined, theCard(null, Tinode.DEL_CHAR));
|
||||
this.props.onUpdateTopicDesc(this.props.topic, theCard(null, Tinode.DEL_CHAR));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ export default class TopicCommonView extends React.Component {
|
||||
this.setState({uploading: true});
|
||||
uploader.upload(blob)
|
||||
.then((url) => {
|
||||
this.props.onUpdateAccount(undefined, theCard(null, url));
|
||||
this.props.onUpdateTopicDesc(this.props.topic, theCard(null, url));
|
||||
})
|
||||
.catch((err) => {
|
||||
this.props.onError(err, 'err');
|
||||
@@ -119,7 +119,7 @@ export default class TopicCommonView extends React.Component {
|
||||
blobToBase64(blob, (unused, base64bits) => {
|
||||
const du = makeImageUrl({data: base64bits, type: mime});
|
||||
this.setState({source: du});
|
||||
this.props.onUpdateAccount(undefined, theCard(null, du));
|
||||
this.props.onUpdateTopicDesc(this.props.topic, theCard(null, du));
|
||||
this.setState({uploading: false});
|
||||
});
|
||||
}
|
||||
|
||||
+30
-45
@@ -921,7 +921,7 @@ class AccSecurityView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Comp
|
||||
this.setState({
|
||||
password: pwd
|
||||
});
|
||||
this.props.onUpdateAccount(pwd);
|
||||
this.props.onUpdatePassword(pwd);
|
||||
}
|
||||
|
||||
handleLaunchPermissionsEditor(which) {
|
||||
@@ -940,7 +940,7 @@ class AccSecurityView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Comp
|
||||
handlePermissionsChanged(perm) {
|
||||
let defacs = {};
|
||||
defacs[this.state.showPermissionEditorFor] = perm;
|
||||
this.props.onUpdateAccount(undefined, undefined, defacs);
|
||||
this.props.onUpdateAccountDesc('me', undefined, undefined, defacs);
|
||||
let newState = {
|
||||
showPermissionEditorFor: undefined
|
||||
};
|
||||
@@ -4616,7 +4616,7 @@ class SidepanelView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compon
|
||||
tinode: this.props.tinode,
|
||||
myUserId: this.props.myUserId,
|
||||
onBasicNavigate: this.props.onBasicNavigate,
|
||||
onUpdateAccount: this.props.onUpdateAccount,
|
||||
onUpdateTopicDesc: this.props.onUpdateAccountDesc,
|
||||
onUpdateTags: this.props.onUpdateAccountTags,
|
||||
onCredAdd: this.props.onCredAdd,
|
||||
onCredDelete: this.props.onCredDelete,
|
||||
@@ -4632,7 +4632,8 @@ class SidepanelView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compon
|
||||
onToggleIncognitoMode: this.props.onToggleIncognitoMode
|
||||
}) : view === 'security' ? react__WEBPACK_IMPORTED_MODULE_0___default().createElement(_acc_security_view_jsx__WEBPACK_IMPORTED_MODULE_10__.default, {
|
||||
tinode: this.props.tinode,
|
||||
onUpdateAccount: this.props.onUpdateAccount,
|
||||
onUpdateAccountDesc: this.props.onUpdateAccountDesc,
|
||||
onUpdatePassword: this.props.onUpdatePassword,
|
||||
onLogout: this.props.onLogout,
|
||||
onDeleteAccount: this.props.onDeleteAccount,
|
||||
onShowAlert: this.props.onShowAlert,
|
||||
@@ -4822,7 +4823,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
this.handleNewChatInvitation = this.handleNewChatInvitation.bind(this);
|
||||
this.handleNewAccount = this.handleNewAccount.bind(this);
|
||||
this.handleNewAccountRequest = this.handleNewAccountRequest.bind(this);
|
||||
this.handleUpdateAccountRequest = this.handleUpdateAccountRequest.bind(this);
|
||||
this.handleUpdatePasswordRequest = this.handleUpdatePasswordRequest.bind(this);
|
||||
this.handleUpdateAccountTagsRequest = this.handleUpdateAccountTagsRequest.bind(this);
|
||||
this.handleToggleIncognitoMode = this.handleToggleIncognitoMode.bind(this);
|
||||
this.handleSettings = this.handleSettings.bind(this);
|
||||
@@ -5690,38 +5691,6 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
});
|
||||
}
|
||||
|
||||
handleUpdateAccountRequest(password, pub, defacs) {
|
||||
this.handleError();
|
||||
|
||||
if (pub || defacs) {
|
||||
const params = {};
|
||||
|
||||
if (pub) {
|
||||
params.public = pub;
|
||||
|
||||
if (pub.photo && pub.photo.ref) {
|
||||
params.attachments = [pub.photo.ref];
|
||||
}
|
||||
}
|
||||
|
||||
if (defacs) {
|
||||
params.defacs = defacs;
|
||||
}
|
||||
|
||||
this.tinode.getMeTopic().setMeta({
|
||||
desc: params
|
||||
}).catch(err => {
|
||||
this.handleError(err.message, 'err');
|
||||
});
|
||||
}
|
||||
|
||||
if (password) {
|
||||
this.tinode.updateAccountBasic(null, this.tinode.getCurrentLogin(), password).catch(err => {
|
||||
this.handleError(err.message, 'err');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleToggleIncognitoMode(on) {
|
||||
const me = this.tinode.getMeTopic();
|
||||
const am = me.getAccessMode().updateWant(on ? '-P' : '+P').getWant();
|
||||
@@ -5976,7 +5945,8 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
}
|
||||
}
|
||||
|
||||
handleTopicUpdateRequest(topicName, pub, priv, permissions) {
|
||||
handleTopicUpdateRequest(topicName, pub, priv, defacs) {
|
||||
this.handleError();
|
||||
const topic = this.tinode.getTopic(topicName);
|
||||
|
||||
if (topic) {
|
||||
@@ -5984,6 +5954,10 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
|
||||
if (pub) {
|
||||
params.public = pub;
|
||||
|
||||
if (pub.photo && pub.photo.ref) {
|
||||
params.attachments = [pub.photo.ref];
|
||||
}
|
||||
}
|
||||
|
||||
if (priv) {
|
||||
@@ -5992,8 +5966,8 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
};
|
||||
}
|
||||
|
||||
if (permissions) {
|
||||
params.defacs = permissions;
|
||||
if (defacs) {
|
||||
params.defacs = defacs;
|
||||
}
|
||||
|
||||
topic.setMeta({
|
||||
@@ -6004,6 +5978,16 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
}
|
||||
}
|
||||
|
||||
handleUpdatePasswordRequest(password) {
|
||||
this.handleError();
|
||||
|
||||
if (password) {
|
||||
this.tinode.updateAccountBasic(null, this.tinode.getCurrentLogin(), password).catch(err => {
|
||||
this.handleError(err.message, 'err');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleChangePermissions(topicName, mode, uid) {
|
||||
const topic = this.tinode.getTopic(topicName);
|
||||
|
||||
@@ -6367,7 +6351,8 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
|
||||
onLoginRequest: this.handleLoginRequest,
|
||||
onPersistenceChange: this.handlePersistenceChange,
|
||||
onCreateAccount: this.handleNewAccountRequest,
|
||||
onUpdateAccount: this.handleUpdateAccountRequest,
|
||||
onUpdateAccountDesc: this.handleTopicUpdateRequest,
|
||||
onUpdatePassword: this.handleUpdatePasswordRequest,
|
||||
onUpdateAccountTags: this.handleUpdateAccountTagsRequest,
|
||||
onTogglePushNotifications: this.togglePushToken,
|
||||
onToggleMessageSounds: this.handleToggleMessageSounds,
|
||||
@@ -6547,7 +6532,7 @@ class TopicCommonView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Comp
|
||||
this.setState({
|
||||
fullName: fn
|
||||
});
|
||||
this.props.onUpdateAccount(undefined, (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_9__.theCard)(fn, null));
|
||||
this.props.onUpdateTopicDesc(this.props.topic, (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_9__.theCard)(fn, null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6558,7 +6543,7 @@ class TopicCommonView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Comp
|
||||
});
|
||||
|
||||
if (!img) {
|
||||
this.props.onUpdateAccount(undefined, (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_9__.theCard)(null, (tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default().DEL_CHAR)));
|
||||
this.props.onUpdateTopicDesc(this.props.topic, (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_9__.theCard)(null, (tinode_sdk__WEBPACK_IMPORTED_MODULE_2___default().DEL_CHAR)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6583,7 +6568,7 @@ class TopicCommonView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Comp
|
||||
uploading: true
|
||||
});
|
||||
uploader.upload(blob).then(url => {
|
||||
this.props.onUpdateAccount(undefined, (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_9__.theCard)(null, url));
|
||||
this.props.onUpdateTopicDesc(this.props.topic, (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_9__.theCard)(null, url));
|
||||
}).catch(err => {
|
||||
this.props.onError(err, 'err');
|
||||
}).finally(() => {
|
||||
@@ -6603,7 +6588,7 @@ class TopicCommonView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Comp
|
||||
this.setState({
|
||||
source: du
|
||||
});
|
||||
this.props.onUpdateAccount(undefined, (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_9__.theCard)(null, du));
|
||||
this.props.onUpdateTopicDesc(this.props.topic, (0,_lib_utils_js__WEBPACK_IMPORTED_MODULE_9__.theCard)(null, du));
|
||||
this.setState({
|
||||
uploading: false
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user