clearing messages works now
This commit is contained in:
+13
-1
@@ -152,6 +152,7 @@ input[type="password"]:focus {
|
|||||||
border-bottom: 1px solid #2196f3;
|
border-bottom: 1px solid #2196f3;
|
||||||
box-shadow: 0 1px 0 rgba(33, 150, 243, 0.25);
|
box-shadow: 0 1px 0 rgba(33, 150, 243, 0.25);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scrollbar styling for Chrome. Firefox does not support scrollbar styling. */
|
/* Scrollbar styling for Chrome. Firefox does not support scrollbar styling. */
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
width: 0.6rem;
|
width: 0.6rem;
|
||||||
@@ -262,6 +263,17 @@ ul.menu > li.separator:hover {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Generic announcement text, centered vertically and horizontally */
|
||||||
|
.center-medium-text {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
/* Class to alternatively hide sidepanel/topic-view */
|
/* Class to alternatively hide sidepanel/topic-view */
|
||||||
.nodisplay {
|
.nodisplay {
|
||||||
display: none!important;
|
display: none!important;
|
||||||
@@ -427,7 +439,7 @@ ul.menu > li.separator:hover {
|
|||||||
background-color: #4caf50;
|
background-color: #4caf50;
|
||||||
}
|
}
|
||||||
.contact-box .offline {
|
.contact-box .offline {
|
||||||
background-color: #888;
|
background-color: #C0C0C0;
|
||||||
}
|
}
|
||||||
/* END of avatar box */
|
/* END of avatar box */
|
||||||
|
|
||||||
|
|||||||
+46
-16
@@ -168,7 +168,9 @@
|
|||||||
console.log("Topic editing not implemented");
|
console.log("Topic editing not implemented");
|
||||||
break;
|
break;
|
||||||
case "Clear messages":
|
case "Clear messages":
|
||||||
topic.delMessages({before: 0, hard: false});
|
topic.delMessagesAll(false).then(function(){
|
||||||
|
console.log("refresh message list");
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case "Mute":
|
case "Mute":
|
||||||
metaParam('-P');
|
metaParam('-P');
|
||||||
@@ -177,10 +179,10 @@
|
|||||||
metaParam('+P');
|
metaParam('+P');
|
||||||
break;
|
break;
|
||||||
case "Block":
|
case "Block":
|
||||||
metaParam('+X');
|
metaParam('-J');
|
||||||
break;
|
break;
|
||||||
case "Unblock":
|
case "Unblock":
|
||||||
metaParam('-X');
|
metaParam('+J');
|
||||||
break;
|
break;
|
||||||
case "Delete":
|
case "Delete":
|
||||||
topic.delTopic();
|
topic.delTopic();
|
||||||
@@ -192,10 +194,10 @@
|
|||||||
var acs = Tinode.getMeTopic().getAccessMode(this.props.topic);
|
var acs = Tinode.getMeTopic().getAccessMode(this.props.topic);
|
||||||
if (Tinode.getTopicType(this.props.topic) === "grp") {
|
if (Tinode.getTopicType(this.props.topic) === "grp") {
|
||||||
return ["Edit...", "Clear messages", acs.isMuted() ? "Unmute" : "Mute",
|
return ["Edit...", "Clear messages", acs.isMuted() ? "Unmute" : "Mute",
|
||||||
acs.isBanned() ? "Unblock" : "Block", "Delete"];
|
!acs.isJoiner() ? "Unblock" : "Block", "Delete"];
|
||||||
} else {
|
} else {
|
||||||
return ["Clear messages", acs.isMuted() ? "Unmute" : "Mute",
|
return ["Clear messages", acs.isMuted() ? "Unmute" : "Mute",
|
||||||
acs.isBanned() ? "Unblock" : "Block", "Delete"];
|
!acs.isJoiner() ? "Unblock" : "Block", "Delete"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -684,6 +686,7 @@
|
|||||||
title = title.substring(0, 28) + "...";
|
title = title.substring(0, 28) + "...";
|
||||||
}
|
}
|
||||||
var selected = (this.props.selected === this.props.topic) ? "selected" : null;
|
var selected = (this.props.selected === this.props.topic) ? "selected" : null;
|
||||||
|
var online = this.props.now ? "online" : "offline";
|
||||||
var avatar = this.props.avatar ?
|
var avatar = this.props.avatar ?
|
||||||
<img src={this.props.avatar} className="avatar" /> :
|
<img src={this.props.avatar} className="avatar" /> :
|
||||||
(Tinode.getTopicType(this.props.topic) === "grp") ?
|
(Tinode.getTopicType(this.props.topic) === "grp") ?
|
||||||
@@ -693,7 +696,7 @@
|
|||||||
<li className={selected} onClick={this.handleClick}>
|
<li className={selected} onClick={this.handleClick}>
|
||||||
<div className="avatar-box">
|
<div className="avatar-box">
|
||||||
{avatar}
|
{avatar}
|
||||||
{this.props.now ? <span className="online"></span> : null}
|
<span className={online} />
|
||||||
</div>
|
</div>
|
||||||
<div className="text-box">
|
<div className="text-box">
|
||||||
<div><span className="contact-title">{title}</span>
|
<div><span className="contact-title">{title}</span>
|
||||||
@@ -807,9 +810,14 @@
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="contacts-panel">
|
<div className="contacts-panel">
|
||||||
|
{contactNodes.length > 0 ?
|
||||||
<ul className="contact-box">
|
<ul className="contact-box">
|
||||||
{contactNodes}
|
{contactNodes}
|
||||||
</ul>
|
</ul>
|
||||||
|
:
|
||||||
|
<p className="center-medium-text">
|
||||||
|
You have no chats<br />¯\_(ツ)_/¯
|
||||||
|
</p>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -830,7 +838,7 @@
|
|||||||
fnd.onSubsUpdated = this.fndSubsUpdated;
|
fnd.onSubsUpdated = this.fndSubsUpdated;
|
||||||
fnd.onMetaDesc = this.fndMetaDesc;
|
fnd.onMetaDesc = this.fndMetaDesc;
|
||||||
if (fnd.isSubscribed()) {
|
if (fnd.isSubscribed()) {
|
||||||
this.setState({searchQuery: fnd.private.toString()});
|
this.setState({searchQuery: fnd.private ? fnd.private.toString() : ''});
|
||||||
} else {
|
} else {
|
||||||
fnd.subscribe({get: {sub: {}, desc: {}}});
|
fnd.subscribe({get: {sub: {}, desc: {}}});
|
||||||
}
|
}
|
||||||
@@ -1168,13 +1176,23 @@
|
|||||||
console.log("topic subscriptions updated");
|
console.log("topic subscriptions updated");
|
||||||
},
|
},
|
||||||
handleNewMessage: function(msg) {
|
handleNewMessage: function(msg) {
|
||||||
|
clearTimeout(this.readTimer);
|
||||||
|
if (msg) {
|
||||||
this.setState({messages: this.state.messages.concat(msg)});
|
this.setState({messages: this.state.messages.concat(msg)});
|
||||||
// Aknowledge all messages, including own messges.
|
// Aknowledge all messages, including own messges.
|
||||||
clearTimeout(this.readTimer);
|
|
||||||
this.readTimer = setTimeout(function() {
|
this.readTimer = setTimeout(function() {
|
||||||
Tinode.getTopic(msg.topic).noteRead(msg.seq);
|
Tinode.getTopic(msg.topic).noteRead(msg.seq);
|
||||||
}, READ_DELAY);
|
}, READ_DELAY);
|
||||||
this.props.onData(msg);
|
this.props.onData(msg);
|
||||||
|
} else {
|
||||||
|
// msg could be null if one or more messages were deleted.
|
||||||
|
// Just regenerate the message list;
|
||||||
|
var _messages = [];
|
||||||
|
Tinode.getTopic(this.state.topic).messages(function(m) {
|
||||||
|
_messages.concat(m);
|
||||||
|
});
|
||||||
|
this.setState({messages: _messages});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
handleInfoReceipt: function(info) {
|
handleInfoReceipt: function(info) {
|
||||||
switch (info.what) {
|
switch (info.what) {
|
||||||
@@ -1462,20 +1480,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (promise) {
|
if (promise) {
|
||||||
this.setState({errorText: ''});
|
|
||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
|
instance.handleLoginSuccessful(instance);
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
|
// Login failed, report error
|
||||||
|
instance.setState({loginDisabled: false, errorText: err.message});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
handleLoginSuccessful: function(instance) {
|
||||||
|
instance.setState({errorText: ''});
|
||||||
|
|
||||||
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
|
// Logged in fine, subscribe to 'me' attaching callbacks from the contacts view.
|
||||||
var me = Tinode.getMeTopic();
|
var me = Tinode.getMeTopic();
|
||||||
me.onMetaDesc = instance.tnMeMetaDesc;
|
me.onMetaDesc = instance.tnMeMetaDesc;
|
||||||
instance.setState({sidePanelSelected: "contacts", loggedIn: true});
|
instance.setState({sidePanelSelected: "contacts", loggedIn: true});
|
||||||
// Subscribe, fetch topic desc, the list of subscriptions, and messages (invites).
|
// Subscribe, fetch topic desc, the list of subscriptions, and messages (invites).
|
||||||
me.subscribe({get: {desc: {}, sub: {}, data: {}}});
|
me.subscribe({get: {desc: {}, sub: {}, data: {}}});
|
||||||
}).catch(function(err) {
|
|
||||||
// Login failed, report error
|
|
||||||
instance.setState({loginDisabled: false, errorText: err.message});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDisconnect: function(err) {
|
handleDisconnect: function(err) {
|
||||||
this.setState({
|
this.setState({
|
||||||
sidePanelSelected: 'login',
|
sidePanelSelected: 'login',
|
||||||
@@ -1535,10 +1560,15 @@
|
|||||||
// Actual registration of a new account.
|
// Actual registration of a new account.
|
||||||
handleNewAccountRequest: function(login_, password_, public_, private_) {
|
handleNewAccountRequest: function(login_, password_, public_, private_) {
|
||||||
var instance = this;
|
var instance = this;
|
||||||
Tinode.connect(this.state.serverAddress).then(function() {
|
Tinode.connect(this.state.serverAddress)
|
||||||
|
.then(function() {
|
||||||
return Tinode.createUserBasic(login_, password_,
|
return Tinode.createUserBasic(login_, password_,
|
||||||
{login: "basic", public: public_, private: private_});
|
{login: "basic", public: public_, private: private_});
|
||||||
}).catch(function(err) {
|
})
|
||||||
|
.then(function() {
|
||||||
|
instance.handleLoginSuccessful(instance);
|
||||||
|
})
|
||||||
|
.catch(function(err) {
|
||||||
instance.setState({errorText: err.message});
|
instance.setState({errorText: err.message});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user