rename readOnly -> !isReader etc

This commit is contained in:
or-else
2019-02-26 16:25:30 +03:00
parent 9193b9be19
commit 0ddb3a4f75
6 changed files with 56 additions and 38 deletions
+16 -20
View File
@@ -112,15 +112,14 @@ class MessagesView extends React.Component {
((!prevProps.connected && this.props.connected) || (this.state.topic != prevState.topic))) { ((!prevProps.connected && this.props.connected) || (this.state.topic != prevState.topic))) {
// Don't request the tags. They are useless unless the user // Don't request the tags. They are useless unless the user
// is the owner and is editing the topic. // is the owner and is editing the topic.
const getQuery = topic.startMetaQuery() let getQuery = topic.startMetaQuery().withLaterDesc().withLaterSub();
.withLaterDesc() if (this.state.isReader) {
.withLaterSub() getQuery = getQuery.withLaterData(MESSAGES_PAGE).withLaterDel();
.withLaterData(MESSAGES_PAGE) // Show "loading" spinner.
.withLaterDel(); this.setState({ fetchingMessages: true });
}
const setQuery = Tinode.isNewGroupTopicName(this.props.topic) ? const setQuery = Tinode.isNewGroupTopicName(this.props.topic) ?
this.props.newGroupTopicParams : undefined; this.props.newGroupTopicParams : undefined;
// Show "loading" spinner.
this.setState({ fetchingMessages: true });
topic.subscribe(getQuery.build(), setQuery) topic.subscribe(getQuery.build(), setQuery)
.then((ctrl) => { .then((ctrl) => {
if (this.state.topic != ctrl.topic) { if (this.state.topic != ctrl.topic) {
@@ -215,13 +214,13 @@ class MessagesView extends React.Component {
} }
} }
let val = nextProps.acs ? !nextProps.acs.isWriter() : true; let val = nextProps.acs ? nextProps.acs.isWriter() : true;
if (val != prevState.readOnly) { if (val != prevState.isWriter) {
nextState.readOnly = val; nextState.isWriter = val;
} }
val = nextProps.acs ? !nextProps.acs.isReader() : true; val = nextProps.acs ? nextProps.acs.isReader() : true;
if (val != prevState.writeOnly) { if (val != prevState.isReader) {
nextState.writeOnly = val; nextState.isReader = val;
} }
val = isUnconfirmed(nextProps.acs); val = isUnconfirmed(nextProps.acs);
if (val != prevState.unconformed) { if (val != prevState.unconformed) {
@@ -301,16 +300,14 @@ class MessagesView extends React.Component {
if (desc.acs) { if (desc.acs) {
this.setState({ this.setState({
readOnly: !desc.acs.isWriter(), isWriter: desc.acs.isWriter(),
writeOnly: !desc.acs.isReader(), isReader: desc.acs.isReader(),
unconfirmed: isUnconfirmed(desc.acs), unconfirmed: isUnconfirmed(desc.acs),
}); });
} }
} }
handleSubsUpdated() { handleSubsUpdated() {
console.log("handleSubsUpdated");
if (this.state.topic) { if (this.state.topic) {
var subs = []; var subs = [];
var topic = this.props.tinode.getTopic(this.state.topic); var topic = this.props.tinode.getTopic(this.state.topic);
@@ -564,9 +561,8 @@ class MessagesView extends React.Component {
<ul id="scroller" className={chatBoxClass}> <ul id="scroller" className={chatBoxClass}>
{messageNodes} {messageNodes}
</ul> </ul>
<div>Typing notifications here.</div>
</div> </div>
{this.state.writeOnly ? {!this.state.isReader ?
<div id="write-only-background"> <div id="write-only-background">
<div id="write-only-note"> <div id="write-only-note">
<FormattedMessage id="messages_not_readable" defaultMessage="no access to messages" <FormattedMessage id="messages_not_readable" defaultMessage="no access to messages"
@@ -583,7 +579,7 @@ class MessagesView extends React.Component {
<SendMessage <SendMessage
tinode={this.props.tinode} tinode={this.props.tinode}
topic={this.props.topic} topic={this.props.topic}
disabled={this.state.readOnly} disabled={!this.state.isWriter}
sendMessage={this.props.sendMessage} sendMessage={this.props.sendMessage}
onError={this.props.onError} /> onError={this.props.onError} />
} }
+8 -1
View File
@@ -738,7 +738,7 @@ class TinodeWeb extends React.Component {
const mode = topic.getAccessMode().getGiven(); const mode = topic.getAccessMode().getGiven();
response = topic.setMeta({sub: {mode: mode}}); response = topic.setMeta({sub: {mode: mode}});
if (topic.getType() == 'p2p') { if (topic.getType() == 'p2p') {
// For P2P topics chage 'given' permission of the peer too. // For P2P topics change 'given' permission of the peer too.
// In p2p topics the other user has the same name as the topic. // In p2p topics the other user has the same name as the topic.
response = response.then((ctrl) => { response = response.then((ctrl) => {
topic.setMeta({sub: {user: topicName, mode: mode}}); topic.setMeta({sub: {user: topicName, mode: mode}});
@@ -752,6 +752,13 @@ class TinodeWeb extends React.Component {
case 'block': case 'block':
// Ban the topic making futher invites impossible. // Ban the topic making futher invites impossible.
response = topic.setMeta({sub: {mode: 'N'}}); response = topic.setMeta({sub: {mode: 'N'}});
if (topic.getType() == 'p2p') {
// For P2P topics change 'given' permission of the peer too.
// In p2p topics the other user has the same name as the topic.
response = response.then((ctrl) => {
topic.setMeta({sub: {user: topicName, mode: 'N'}});
});
}
break; break;
default: default:
console.log("Unknown invitation action", '"' + action + '""'); console.log("Unknown invitation action", '"' + action + '""');
+29 -14
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