simplifies InfoView parameters

This commit is contained in:
or-else
2018-08-19 10:58:22 +03:00
parent be8d64e29e
commit f782bc11cc
2 changed files with 18 additions and 27 deletions
-1
View File
@@ -17,7 +17,6 @@ Background pattern from http://subtlepatterns.com/, commercial and non-commercia
## Missing functionality ## Missing functionality
* Previews not generated for videos, audio, links or docs. * Previews not generated for videos, audio, links or docs.
* No indication of some chat statuses (muted, blocked, etc.).
* Browser push notifications are not implemented. * Browser push notifications are not implemented.
* No end-to-end encryption. * No end-to-end encryption.
* Editing chat permissions is incomplete. * Editing chat permissions is incomplete.
+18 -26
View File
@@ -418,7 +418,7 @@ function arrayEqual(a, b) {
function topicPermissionSetter(mode, params, errorHandler) { function topicPermissionSetter(mode, params, errorHandler) {
var topic = Tinode.getTopic(params.topicName); var topic = Tinode.getTopic(params.topicName);
if (!topic) { if (!topic) {
console.log("Topic not found: " + params.topicName); console.log("Topic not found", params.topicName);
return; return;
} }
@@ -426,7 +426,7 @@ function topicPermissionSetter(mode, params, errorHandler) {
if (params.user) { if (params.user) {
user = topic.subscriber(params.user); user = topic.subscriber(params.user);
if (!user) { if (!user) {
console.log("Subscriber not found: " + params.topicName + "[" + params.user + "]"); console.log("Subscriber not found", params.topicName + "[" + params.user + "]");
return; return;
} }
am = user.acs.updateGiven(mode).getGiven(); am = user.acs.updateGiven(mode).getGiven();
@@ -445,7 +445,7 @@ function topicPermissionSetter(mode, params, errorHandler) {
function deleteMessages(all, hard, params, errorHandler) { function deleteMessages(all, hard, params, errorHandler) {
var topic = Tinode.getTopic(params.topicName); var topic = Tinode.getTopic(params.topicName);
if (!topic) { if (!topic) {
console.log("Topic not found: " + params.topicName); console.log("Topic not found: ", params.topicName);
return; return;
} }
var promise = all ? var promise = all ?
@@ -481,7 +481,7 @@ var ContextMenuItems = {
"topic_delete": {title: "Delete", handler: function(params, errorHandler) { "topic_delete": {title: "Delete", handler: function(params, errorHandler) {
var topic = Tinode.getTopic(params.topicName); var topic = Tinode.getTopic(params.topicName);
if (!topic) { if (!topic) {
console.log("Topic not found: " + params.topicName); console.log("Topic not found: ", params.topicName);
return; return;
} }
topic.delTopic().catch(function(err) { topic.delTopic().catch(function(err) {
@@ -2117,11 +2117,12 @@ class ContactsView extends React.Component {
if (this.props.topicSelected === cont.topic) { if (this.props.topicSelected === cont.topic) {
this.props.onAcsChange(cont.acs); this.props.onAcsChange(cont.acs);
} }
} else if (what == "del") {
// messages deleted (hard or soft) -- update pill counter.
} else { } else {
// TODO(gene): handle other types of notifications: // TODO(gene): handle other types of notifications:
// * ua -- user agent changes (maybe display a pictogram for mobile/desktop). // * ua -- user agent changes (maybe display a pictogram for mobile/desktop).
// * upd -- topic 'public' updated, issue getMeta(). // * upd -- topic 'public' updated, issue getMeta().
// * del -- messages deleted (hard or soft) -- reset pill counter.
console.log("Unsupported (yet) presence update:" + what + " in: " + cont.topic); console.log("Unsupported (yet) presence update:" + what + " in: " + cont.topic);
} }
} }
@@ -2783,7 +2784,7 @@ class InfoView extends React.Component {
anon: null, anon: null,
contactList: [], contactList: [],
tags: [], tags: [],
showMemberPanel: props.showMemberPanel, showMemberPanel: false,
showPermissionEditorFor: undefined, showPermissionEditorFor: undefined,
moreInfoExpanded: false, moreInfoExpanded: false,
previousMetaDesc: undefined, previousMetaDesc: undefined,
@@ -2791,7 +2792,6 @@ class InfoView extends React.Component {
previousTagsUpdated: undefined previousTagsUpdated: undefined
}; };
this.initInfoView = this.initInfoView.bind(this);
this.resetSubs = this.resetSubs.bind(this); this.resetSubs = this.resetSubs.bind(this);
this.resetDesc = this.resetDesc.bind(this); this.resetDesc = this.resetDesc.bind(this);
this.onMetaDesc = this.onMetaDesc.bind(this); this.onMetaDesc = this.onMetaDesc.bind(this);
@@ -2814,7 +2814,8 @@ class InfoView extends React.Component {
this.handleContextMenu = this.handleContextMenu.bind(this); this.handleContextMenu = this.handleContextMenu.bind(this);
} }
initInfoView(props) { // No need to separately handle componentWillMount.
componentWillReceiveProps(props) {
var topic = Tinode.getTopic(props.topic); var topic = Tinode.getTopic(props.topic);
if (!topic) { if (!topic) {
return; return;
@@ -2842,11 +2843,6 @@ class InfoView extends React.Component {
} }
} }
// No need to separately handle componentWillMount.
componentWillReceiveProps(nextProps) {
this.initInfoView(nextProps);
}
componentWillUnmount() { componentWillUnmount() {
var topic = Tinode.getTopic(this.props.topic); var topic = Tinode.getTopic(this.props.topic);
if (!topic) { if (!topic) {
@@ -2891,6 +2887,7 @@ class InfoView extends React.Component {
private: topic.private ? topic.private.comment : null, private: topic.private ? topic.private.comment : null,
address: topic.name, address: topic.name,
groupTopic: (topic.getType() === "grp"), groupTopic: (topic.getType() === "grp"),
showMemberPanel: false,
access: acs ? acs.getMode() : undefined, access: acs ? acs.getMode() : undefined,
modeGiven: acs ? acs.getGiven() : undefined, modeGiven: acs ? acs.getGiven() : undefined,
modeWant: acs ? acs.getWant() : undefined, modeWant: acs ? acs.getWant() : undefined,
@@ -4331,7 +4328,6 @@ class TinodeWeb extends React.Component {
loginDisabled: false, loginDisabled: false,
displayMobile: (window.innerWidth <= MEDIA_BREAKPOINT), displayMobile: (window.innerWidth <= MEDIA_BREAKPOINT),
showInfoPanel: false, showInfoPanel: false,
infoPanelShowMembers: false,
mobilePanel: 'sidepanel', mobilePanel: 'sidepanel',
contextMenuVisible: false, contextMenuVisible: false,
contextMenuBounds: null, contextMenuBounds: null,
@@ -4658,7 +4654,7 @@ class TinodeWeb extends React.Component {
mobilePanel: 'topic-view', mobilePanel: 'topic-view',
topicSelectedOnline: online, topicSelectedOnline: online,
topicSelectedAcs: acs, topicSelectedAcs: acs,
infoPanelShowMembers: Tinode.topicType(topicName) === "grp" showInfoPanel: false
}); });
} else { } else {
if (this.state.topicSelected) { if (this.state.topicSelected) {
@@ -4671,7 +4667,7 @@ class TinodeWeb extends React.Component {
mobilePanel: 'sidepanel', mobilePanel: 'sidepanel',
topicSelectedOnline: false, topicSelectedOnline: false,
topicSelectedAcs: null, topicSelectedAcs: null,
infoPanelShowMembers: false showInfoPanel: false
}); });
} }
} }
@@ -4877,15 +4873,12 @@ class TinodeWeb extends React.Component {
if (!topic) { if (!topic) {
return; return;
} }
var instance = this;
topic.leave(true).then(function(ctrl) { topic.leave(true).then((ctrl) => {
// Hide MessagesView and InfoView panels. // Hide MessagesView and InfoView panels.
window.location.hash = setUrlTopic(window.location.hash, ''); window.location.hash = setUrlTopic(window.location.hash, '');
instance.setState({ }).catch((err) => {
infoPanelShowMembers: false this.handleError(err.message, "err");
});
}).catch(function(err) {
instance.handleError(err.message, "err");
}); });
} }
@@ -4937,12 +4930,12 @@ class TinodeWeb extends React.Component {
handleShowInfoView() { handleShowInfoView() {
window.location.hash = addUrlParam(window.location.hash, 'info', true); window.location.hash = addUrlParam(window.location.hash, 'info', true);
this.setState({showInfoPanel: true, infoPanelShowMembers: false}); this.setState({showInfoPanel: true});
} }
handleHideInfoView() { handleHideInfoView() {
window.location.hash = removeUrlParam(window.location.hash, 'info'); window.location.hash = removeUrlParam(window.location.hash, 'info');
this.setState({showInfoPanel: false, infoPanelShowMembers: false}); this.setState({showInfoPanel: false});
} }
handleMemberUpdateRequest(topicName, added, removed) { handleMemberUpdateRequest(topicName, added, removed) {
@@ -5065,7 +5058,6 @@ class TinodeWeb extends React.Component {
errorText={this.state.errorText} errorText={this.state.errorText}
errorLevel={this.state.errorLevel} errorLevel={this.state.errorLevel}
showMemberPanel={this.state.infoPanelShowMembers}
onTopicDescUpdate={this.handleTopicUpdateRequest} onTopicDescUpdate={this.handleTopicUpdateRequest}
onCancel={this.handleHideInfoView} onCancel={this.handleHideInfoView}
onChangePermissions={this.handleChangePermissions} onChangePermissions={this.handleChangePermissions}