merged with next

This commit is contained in:
or-else
2022-05-26 10:16:09 -07:00
30 changed files with 844 additions and 4008 deletions
+12 -15
View File
@@ -241,16 +241,6 @@ class MessagesView extends React.Component {
} else if (nextProps.topic != prevState.topic) {
const topic = nextProps.tinode.getTopic(nextProps.topic);
let reply = null;
if (nextProps.forwardMessage) {
// We are forwarding a message. Show preview.
const preview = nextProps.forwardMessage.preview;
reply = {
content: preview,
seq: null
};
}
nextState = {
topic: nextProps.topic,
docPreview: null,
@@ -260,11 +250,18 @@ class MessagesView extends React.Component {
typingIndicator: false,
scrollPosition: 0,
fetchingMessages: false,
reply: reply,
showGoToLastButton: false,
deleted: topic._deleted
};
if (nextProps.forwardMessage) {
// We are forwarding a message. Show preview.
nextState.reply = {
content: nextProps.forwardMessage.preview,
seq: null
};
}
if (topic) {
// Topic exists.
const subs = [];
@@ -461,7 +458,8 @@ class MessagesView extends React.Component {
const pos = event.target.scrollHeight - event.target.scrollTop - event.target.offsetHeight;
this.setState({
scrollPosition: pos,
showGoToLastButton: pos > SHOW_GO_TO_LAST_DIST,
// Show [go to latest message] if far enough from bottom and scrolling down.
showGoToLastButton: (pos > SHOW_GO_TO_LAST_DIST) && (pos < this.state.scrollPosition),
});
if (this.state.fetchingMessages) {
@@ -609,8 +607,8 @@ class MessagesView extends React.Component {
clearTimeout(this.keyPressTimer)
this.setState({messageCount: topic.messageCount(), typingIndicator: false});
// Scroll to the bottom if the message is added to the end of the message list.
// TODO: This should be replaced by showing a "scroll to bottom" button.
// Scroll to the bottom if the message is added to the end of the message
// list if already at the bottom, otherwise show [go to latest] button.
if (topic.isNewMessage(msg.seq)) {
if (this.state.scrollPosition > SHOW_GO_TO_LAST_DIST) {
this.setState({showGoToLastButton: true});
@@ -961,7 +959,6 @@ class MessagesView extends React.Component {
// seq: seq ID of the source message
// context: message content.
// forwarded: true if the source message is also a forwarded message.
// senderId: UID of the sender of the source message.
// senderName: full name of the sender of the original message.
handlePickReply(seq, content, senderId, senderName) {
+8 -16
View File
@@ -347,21 +347,7 @@ class TinodeWeb extends React.Component {
// Tinode received a push notification from the server.
handlePushMessage(payload) {
const data = payload.data || {};
switch (data.what) {
case 'msg':
if (Tinode.isChannelTopicName(data.topic)) {
// The last argument is a fake user Id: otherwise the update is seen as one from the current user.
this.tinode.oobNotification('msg', data.topic, data.seq, 'fake-uid');
}
break;
case 'read':
// Message read on another device, clear it here.
this.tinode.oobNotification('read', data.topic, data.seq);
break;
default:
console.warn("Unknown push type ignored", data.what, data);
}
this.tinode.oobNotification(payload.data || {});
}
initFCMessaging() {
@@ -622,7 +608,7 @@ class TinodeWeb extends React.Component {
this.handleError(
formatMessage(messages.reconnect_countdown, {seconds: timeLeft}),
'warn',
() => {
_ => {
clearInterval(this.reconnectCountdown);
this.tinode.reconnect();
},
@@ -1532,6 +1518,12 @@ class TinodeWeb extends React.Component {
defaultTopicContextMenu(topicName) {
const topic = this.tinode.getTopic(topicName);
if (topic._deleted) {
return [
'topic_delete'
];
}
let muted = false, blocked = false, self_blocked = false, subscribed = false, deleter = false, archived = false;
if (topic) {
subscribed = topic.isSubscribed();