Merge branch 'devel' into features
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "tinode-webapp",
|
"name": "tinode-webapp",
|
||||||
"description": "Tinode messenger for the web",
|
"description": "Tinode messenger for the web",
|
||||||
"version": "0.17.9",
|
"version": "0.17.10-rc1",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/tinode/example-react-js.git"
|
"url": "https://github.com/tinode/example-react-js.git"
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-intl": "^5.20.2",
|
"react-intl": "^5.20.2",
|
||||||
"tinode-sdk": "^0.17.9"
|
"tinode-sdk": "^0.17.10-rc1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.14.5",
|
"@babel/core": "^7.14.5",
|
||||||
|
|||||||
+1
-1
@@ -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.17.9";
|
export const PACKAGE_VERSION = "0.17.10-rc1";
|
||||||
|
|||||||
+19
-23
@@ -124,7 +124,7 @@ class MessagesView extends React.Component {
|
|||||||
// or vertical shrinking.
|
// or vertical shrinking.
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
if (this.messagesScroller) {
|
if (this.messagesScroller) {
|
||||||
if (prevState.topic != this.state.topic || prevState.latestMsgSeq != this.state.latestMsgSeq) {
|
if (prevState.topic != this.state.topic || prevState.messageCount != this.state.messageCount) {
|
||||||
// New message
|
// New message
|
||||||
this.messagesScroller.scrollTop = this.messagesScroller.scrollHeight - this.state.scrollPosition;
|
this.messagesScroller.scrollTop = this.messagesScroller.scrollHeight - this.state.scrollPosition;
|
||||||
} else if (prevProps.viewportHeight > this.props.viewportHeight) {
|
} else if (prevProps.viewportHeight > this.props.viewportHeight) {
|
||||||
@@ -208,7 +208,7 @@ class MessagesView extends React.Component {
|
|||||||
if (!nextProps.topic) {
|
if (!nextProps.topic) {
|
||||||
// Default state: no topic.
|
// Default state: no topic.
|
||||||
nextState = {
|
nextState = {
|
||||||
latestMsgSeq: -1,
|
messageCount: 0,
|
||||||
latestClearId: -1,
|
latestClearId: -1,
|
||||||
onlineSubs: [],
|
onlineSubs: [],
|
||||||
topic: null,
|
topic: null,
|
||||||
@@ -274,14 +274,14 @@ class MessagesView extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
Object.assign(nextState, {
|
Object.assign(nextState, {
|
||||||
latestMsgSeq: topic.maxMsgSeq(),
|
messageCount: topic.messageCount(),
|
||||||
latestClearId: topic.maxClearId(),
|
latestClearId: topic.maxClearId(),
|
||||||
channel: topic.isChannelType()
|
channel: topic.isChannelType()
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Invalid topic.
|
// Invalid topic.
|
||||||
Object.assign(nextState, {
|
Object.assign(nextState, {
|
||||||
latestMsgSeq: -1,
|
messageCount: 0,
|
||||||
latestClearId: -1,
|
latestClearId: -1,
|
||||||
onlineSubs: [],
|
onlineSubs: [],
|
||||||
title: '',
|
title: '',
|
||||||
@@ -365,23 +365,19 @@ class MessagesView extends React.Component {
|
|||||||
// Get older messages
|
// Get older messages
|
||||||
handleScrollEvent(event) {
|
handleScrollEvent(event) {
|
||||||
this.setState({scrollPosition: event.target.scrollHeight - event.target.scrollTop});
|
this.setState({scrollPosition: event.target.scrollHeight - event.target.scrollTop});
|
||||||
|
if (this.state.fetchingMessages) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.target.scrollTop <= 0) {
|
if (event.target.scrollTop <= 0) {
|
||||||
this.setState((prevState, props) => {
|
const topic = this.props.tinode.getTopic(this.state.topic);
|
||||||
const newState = {};
|
if (topic && topic.isSubscribed() && topic.msgHasMoreMessages()) {
|
||||||
if (!prevState.fetchingMessages) {
|
this.setState({fetchingMessages: true}, () => {
|
||||||
const topic = this.props.tinode.getTopic(this.state.topic);
|
topic.getMessagesPage(MESSAGES_PAGE)
|
||||||
if (topic && topic.isSubscribed() && topic.msgHasMoreMessages()) {
|
.catch((err) => this.props.onError(err.message, 'err'))
|
||||||
newState.fetchingMessages = true;
|
.finally(() => this.setState({fetchingMessages: false}));
|
||||||
topic.getMessagesPage(MESSAGES_PAGE)
|
});
|
||||||
.then(() => this.setState({fetchingMessages: false}))
|
}
|
||||||
.catch((err) => {
|
|
||||||
this.setState({fetchingMessages: false});
|
|
||||||
this.props.onError(err.message, 'err');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newState;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -504,10 +500,10 @@ class MessagesView extends React.Component {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({latestMsgSeq: topic.maxMsgSeq()});
|
this.setState({messageCount: topic.messageCount()});
|
||||||
|
|
||||||
// If the message is added to the end of the message list,
|
// Scroll to the bottom if the message is added to the end of the message list.
|
||||||
// scroll to the bottom.
|
// TODO: This should be replaced by showing a "scroll to bottom" button.
|
||||||
if (topic.isNewMessage(msg.seq)) {
|
if (topic.isNewMessage(msg.seq)) {
|
||||||
this.setState({scrollPosition: 0});
|
this.setState({scrollPosition: 0});
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-36
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+39
-32
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
// This is a generated file. Don't edit.
|
// This is a generated file. Don't edit.
|
||||||
|
|
||||||
const PACKAGE_VERSION = "0.17.9";
|
const PACKAGE_VERSION = "0.17.10-rc1";
|
||||||
|
|||||||
Reference in New Issue
Block a user