making AccGeneralView more generic, using msg.extra for attachments

This commit is contained in:
or-else
2021-07-16 12:57:30 -07:00
parent 0cd432a52f
commit b704499308
8 changed files with 399 additions and 389 deletions
+1 -1
View File
@@ -587,7 +587,7 @@
},
"sidepanel_title_acc_general": {
"defaultMessage": "General",
"description": "Sidepanel title for AccGeneralView."
"description": "Sidepanel title for TopicCommonView."
},
"sidepanel_title_acc_notifications": {
"defaultMessage": "Notifications",
+4 -3
View File
@@ -8,7 +8,7 @@ import SideNavbar from '../widgets/side-navbar.jsx';
import ContactsView from './contacts-view.jsx';
import CreateAccountView from './create-account-view.jsx';
import EditAccountView from './edit-account-view.jsx';
import AccGeneralView from './acc-general-view.jsx';
import TopicCommonView from './topic-common-view.jsx';
import AccNotificationsView from './acc-notifications-view.jsx';
import AccSecurityView from './acc-security-view.jsx';
import AccSupportView from './acc-support-view.jsx';
@@ -42,7 +42,7 @@ const messages = defineMessages({
},
general: {
id: 'sidepanel_title_acc_general',
description: 'Sidepanel title for AccGeneralView.',
description: 'Sidepanel title for TopicCommonView.',
defaultMessage: 'General'
},
security: {
@@ -176,7 +176,8 @@ class SidepanelView extends React.Component {
onBasicNavigate={this.props.onBasicNavigate} /> :
(view === 'general' || view === 'crop') ?
<AccGeneralView
<TopicCommonView
topic="me"
tinode={this.props.tinode}
myUserId={this.props.myUserId}
onBasicNavigate={this.props.onBasicNavigate}
+3
View File
@@ -987,6 +987,9 @@ class TinodeWeb extends React.Component {
const params = {};
if (pub) {
params.public = pub;
if (pub.photo && pub.photo.ref) {
params.attachments = [pub.photo.ref];
}
}
if (defacs) {
params.defacs = defacs;
@@ -1,4 +1,5 @@
// Edit account parameters.
// View for editing topic (including 'me' topic) parameters.
import React from 'react';
import { FormattedMessage } from 'react-intl';
@@ -15,22 +16,22 @@ import { AVATAR_SIZE, MAX_AVATAR_BYTES, MAX_EXTERN_ATTACHMENT_SIZE,
import { imageScaled, blobToBase64, makeImageUrl } from '../lib/blob-helpers.js';
import { arrayEqual, asEmail, asPhone, theCard } from '../lib/utils.js';
export default class AccGeneralView extends React.Component {
export default class TopicCommonView extends React.Component {
constructor(props) {
super(props);
const me = this.props.tinode.getMeTopic();
const topic = this.props.tinode.getTopic(this.props.topic);
this.state = {
fullName: me.public ? me.public.fn : undefined,
avatar: makeImageUrl(me.public ? me.public.photo : null),
tags: me.tags(),
credentials: me.getCredentials() || [],
fullName: topic.public ? topic.public.fn : undefined,
avatar: makeImageUrl(topic.public ? topic.public.photo : null),
tags: topic.tags(),
credentials: topic.getCredentials() || [],
addCredActive: false,
addCredInvalid: false,
newCred: '',
newAvatar: null,
newAvatarMime: null,
previousOnTags: me.onTagsUpdated
previousOnTags: topic.onTagsUpdated
};
this.tnNewTags = this.tnNewTags.bind(this);
@@ -47,15 +48,15 @@ export default class AccGeneralView extends React.Component {
}
componentDidMount() {
const me = this.props.tinode.getMeTopic();
me.onCredsUpdated = this.tnCredsUpdated;
me.onTagsUpdated = this.tnNewTags;
const topic = this.props.tinode.getTopic(this.props.topic);
topic.onCredsUpdated = this.tnCredsUpdated;
topic.onTagsUpdated = this.tnNewTags;
}
componentWillUnmount() {
const me = this.props.tinode.getMeTopic();
me.onTagsUpdated = this.state.previousOnTags;
me.onCredsUpdated = undefined;
const topic = this.props.tinode.getTopic(this.props.topic);
topic.onTagsUpdated = this.state.previousOnTags;
topic.onCredsUpdated = undefined;
}
tnNewTags(tags) {