bug fixes: crash in editing group member permissions, fnd not working sometimes, var -> let, const

This commit is contained in:
or-else
2018-12-13 15:42:54 +03:00
parent 10d88da558
commit bc3e82bcbf
12 changed files with 49 additions and 85 deletions
+1 -1
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.15.10", "version": "0.15.11-rc1",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.1.2", "@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0", "@babel/preset-env": "^7.1.0",
+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.15.10"; export const PACKAGE_VERSION = "0.15.11-rc1";
+11 -8
View File
@@ -97,8 +97,8 @@ class InfoView extends React.Component {
} }
// No need to separately handle component mount. // No need to separately handle component mount.
UNSAFE_componentWillReceiveProps(props) { componentDidUpdate(props) {
var topic = this.props.tinode.getTopic(props.topic); let topic = this.props.tinode.getTopic(props.topic);
if (!topic) { if (!topic) {
return; return;
} }
@@ -137,17 +137,17 @@ class InfoView extends React.Component {
} }
resetSubs(topic, props) { resetSubs(topic, props) {
var newState = {contactList: []}; const newState = {contactList: []};
if (topic.getType() == 'p2p') { if (topic.getType() == 'p2p') {
// Fetch the other party in the p2p conversation. // Fetch the other party in the p2p conversation.
// Topic may not be ready yet, so check if user is found. // Topic may not be ready yet, so check if user is found.
var user2 = topic.subscriber(props.topic); const user2 = topic.subscriber(props.topic);
if (user2) { if (user2) {
newState.modeGiven2 = user2.acs.getGiven(); newState.modeGiven2 = user2.acs.getGiven();
newState.modeWant2 = user2.acs.getWant(); newState.modeWant2 = user2.acs.getWant();
} }
} else { } else {
topic.subscribers(function(sub) { topic.subscribers((sub) => {
newState.contactList.push(sub); newState.contactList.push(sub);
}, this); }, this);
} }
@@ -156,12 +156,15 @@ class InfoView extends React.Component {
} }
resetDesc(topic, props) { resetDesc(topic, props) {
var defacs = topic.getDefaultAccess() || {}; const defacs = topic.getDefaultAccess() || {};
var acs = topic.getAccessMode(); const acs = topic.getAccessMode();
console.log("Desc:", defacs, acs);
this.setState({ this.setState({
owner: acs && acs.isOwner(), owner: acs && acs.isOwner(),
admin: acs && acs.isAdmin(), admin: acs && acs.isAdmin(),
sharer: acs && (acs.isAdmin() || acs.isSharer()), sharer: acs && acs.isSharer(),
muted: acs && acs.isMuted(), muted: acs && acs.isMuted(),
fullName: topic.public ? topic.public.fn : undefined, fullName: topic.public ? topic.public.fn : undefined,
+2 -10
View File
@@ -15,8 +15,7 @@ export default class NewTopicView extends React.Component {
super(props); super(props);
this.state = { this.state = {
tabSelected: 'p2p', tabSelected: 'p2p'
contactList: props.searchResults
}; };
this.handleTabClick = this.handleTabClick.bind(this); this.handleTabClick = this.handleTabClick.bind(this);
@@ -29,12 +28,6 @@ export default class NewTopicView extends React.Component {
this.props.onInitFind(); this.props.onInitFind();
} }
static getDerivedStateFromProps(nextProps, prevState) {
return {
contactList: nextProps.searchResults
};
}
handleTabClick(e) { handleTabClick(e) {
e.preventDefault(); e.preventDefault();
HashNavigation.navigateTo(HashNavigation.addUrlParam(window.location.hash, 'tab', e.currentTarget.dataset.id)); HashNavigation.navigateTo(HashNavigation.addUrlParam(window.location.hash, 'tab', e.currentTarget.dataset.id));
@@ -93,10 +86,9 @@ export default class NewTopicView extends React.Component {
<FormattedMessage id="search_for_contacts" defaultMessage="Use search to find contacts" <FormattedMessage id="search_for_contacts" defaultMessage="Use search to find contacts"
description="Prompt in search field.">{ description="Prompt in search field.">{
(search_for_contacts) => <ContactList (search_for_contacts) => <ContactList
contacts={this.state.contactList} contacts={this.props.searchResults}
myUserId={this.props.myUserId} myUserId={this.props.myUserId}
emptyListMessage={search_for_contacts} emptyListMessage={search_for_contacts}
topicSelected={this.state.selectedContact}
showOnline={false} showOnline={false}
showUnread={false} showUnread={false}
showContextMenu={false} showContextMenu={false}
+9 -9
View File
@@ -552,7 +552,7 @@ class TinodeWeb extends React.Component {
// Sending "received" notifications // Sending "received" notifications
tnData(data) { tnData(data) {
let topic = this.tinode.getTopic(data.topic); const topic = this.tinode.getTopic(data.topic);
if (topic.msgStatus(data) >= Tinode.MESSAGE_STATUS_SENT) { if (topic.msgStatus(data) >= Tinode.MESSAGE_STATUS_SENT) {
clearTimeout(this.receivedTimer); clearTimeout(this.receivedTimer);
this.receivedTimer = setTimeout(() => { this.receivedTimer = setTimeout(() => {
@@ -564,11 +564,11 @@ class TinodeWeb extends React.Component {
/* Fnd topic: find contacts by tokens */ /* Fnd topic: find contacts by tokens */
tnInitFind() { tnInitFind() {
let fnd = this.tinode.getFndTopic(); const fnd = this.tinode.getFndTopic();
fnd.onSubsUpdated = this.tnFndSubsUpdated;
if (fnd.isSubscribed()) { if (fnd.isSubscribed()) {
this.tnFndSubsUpdated(); this.tnFndSubsUpdated();
} else { } else {
fnd.onSubsUpdated = this.tnFndSubsUpdated;
fnd.subscribe(fnd.startMetaQuery().withSub().withTags().build()).catch((err) => { fnd.subscribe(fnd.startMetaQuery().withSub().withTags().build()).catch((err) => {
this.handleError(err.message, 'err'); this.handleError(err.message, 'err');
}); });
@@ -576,7 +576,7 @@ class TinodeWeb extends React.Component {
} }
tnFndSubsUpdated() { tnFndSubsUpdated() {
let foundContacts = []; const foundContacts = [];
// Don't attempt to create P2P topics which already exist. Server will reject the duplicates. // Don't attempt to create P2P topics which already exist. Server will reject the duplicates.
this.tinode.getFndTopic().contacts((s) => { this.tinode.getFndTopic().contacts((s) => {
foundContacts.push(s); foundContacts.push(s);
@@ -591,7 +591,7 @@ class TinodeWeb extends React.Component {
@param query {Array} is an array of contacts to search for @param query {Array} is an array of contacts to search for
*/ */
handleSearchContacts(query) { handleSearchContacts(query) {
var fnd = this.tinode.getFndTopic(); const fnd = this.tinode.getFndTopic();
fnd.setMeta({desc: {public: query}}).then((ctrl) => { fnd.setMeta({desc: {public: query}}).then((ctrl) => {
return fnd.getMeta(fnd.startMetaQuery().withSub().build()); return fnd.getMeta(fnd.startMetaQuery().withSub().build());
}).catch((err) => { }).catch((err) => {
@@ -848,9 +848,9 @@ class TinodeWeb extends React.Component {
} }
handleTopicUpdateRequest(topicName, pub, priv, permissions) { handleTopicUpdateRequest(topicName, pub, priv, permissions) {
var topic = this.tinode.getTopic(topicName); const topic = this.tinode.getTopic(topicName);
if (topic) { if (topic) {
var params = {}; const params = {};
if (pub) { if (pub) {
params.public = pub; params.public = pub;
} }
@@ -868,9 +868,9 @@ class TinodeWeb extends React.Component {
} }
handleChangePermissions(topicName, mode, uid) { handleChangePermissions(topicName, mode, uid) {
var topic = this.tinode.getTopic(topicName); const topic = this.tinode.getTopic(topicName);
if (topic) { if (topic) {
var am = topic.getAccessMode(); const am = topic.getAccessMode();
if (uid) { if (uid) {
am.updateGiven(mode); am.updateGiven(mode);
mode = am.getGiven(); mode = am.getGiven();
+5 -5
View File
@@ -27,11 +27,11 @@ class ContactList extends React.Component {
const contactNodes = []; const contactNodes = [];
if (this.props.contacts && this.props.contacts.length > 0) { if (this.props.contacts && this.props.contacts.length > 0) {
this.props.contacts.map((c) => { this.props.contacts.map((c) => {
var key = c.topic ? c.topic : c.user; let key = c.topic ? c.topic : c.user;
// If filter function is provided, filter out the items // If filter function is provided, filter out the items
// which don't satisfy the condition. // which don't satisfy the condition.
if (this.props.filterFunc && this.props.filter) { if (this.props.filterFunc && this.props.filter) {
var content = [key]; let content = [key];
if (c.private && c.private.comment) { if (c.private && c.private.comment) {
content.push(('' + c.private.comment).toLowerCase()); content.push(('' + c.private.comment).toLowerCase());
} }
@@ -43,10 +43,10 @@ class ContactList extends React.Component {
} }
} }
var selected = showCheckmark ? let selected = showCheckmark ?
(this.props.topicSelected.indexOf(key) > -1) : (this.props.topicSelected.indexOf(key) > -1) :
(this.props.topicSelected === key); (this.props.topicSelected === key);
var badges = []; let badges = [];
if (this.props.showMode) { if (this.props.showMode) {
if (key === this.props.myUserId) { if (key === this.props.myUserId) {
badges.push({name: formatMessage(messages.badge_you), color: 'green'}); badges.push({name: formatMessage(messages.badge_you), color: 'green'});
@@ -55,7 +55,7 @@ class ContactList extends React.Component {
badges.push({name: formatMessage(messages.badge_owner), color: 'blue'}); badges.push({name: formatMessage(messages.badge_owner), color: 'blue'});
} }
} }
var comment = Array.isArray(c.private) ? let comment = Array.isArray(c.private) ?
c.private.join(',') : (c.private ? c.private.comment : null); c.private.join(',') : (c.private ? c.private.comment : null);
contactNodes.push( contactNodes.push(
+3 -3
View File
@@ -36,9 +36,9 @@ export default class Contact extends React.Component {
// FIXME: this is probably wrong for RTL languages. // FIXME: this is probably wrong for RTL languages.
title = title.substring(0, 28) + '...'; title = title.substring(0, 28) + '...';
} }
let online = this.props.now ? 'online' : 'offline'; const online = this.props.now ? 'online' : 'offline';
let avatar = this.props.avatar ? this.props.avatar : true; const avatar = this.props.avatar ? this.props.avatar : true;
let badges = this.props.badges.slice(); const badges = this.props.badges ? this.props.badges.slice() : [];
if (this.props.showMode && this.props.acs) { if (this.props.showMode && this.props.acs) {
badges.push({name: this.props.acs.getMode(), key: 'mode'}); badges.push({name: this.props.acs.getMode(), key: 'mode'});
} }
+2 -12
View File
@@ -8,21 +8,11 @@ import { makeImageUrl } from '../lib/blob-helpers.js';
export default class GroupSubs extends React.Component { export default class GroupSubs extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = {
onlineSubs: props.subscribers || []
};
}
static getDerivedStateFromProps(nextProps, prevState) {
return {
onlineSubs: nextProps.subscribers ? nextProps.subscribers : []
};
} }
render() { render() {
var usersOnline = []; const usersOnline = [];
this.state.onlineSubs.map((sub) => { (this.props.subscribers || []).map((sub) => {
usersOnline.push( usersOnline.push(
<div className="avatar-box" key={sub.user}> <div className="avatar-box" key={sub.user}>
<LetterTile <LetterTile
+12 -33
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
+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