fix a race condition in handleScrollEvent (#85)
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";
|
||||||
|
|||||||
@@ -365,24 +365,20 @@ 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 newState = {};
|
|
||||||
if (!prevState.fetchingMessages) {
|
|
||||||
const topic = this.props.tinode.getTopic(this.state.topic);
|
const topic = this.props.tinode.getTopic(this.state.topic);
|
||||||
if (topic && topic.isSubscribed() && topic.msgHasMoreMessages()) {
|
if (topic && topic.isSubscribed() && topic.msgHasMoreMessages()) {
|
||||||
newState.fetchingMessages = true;
|
this.setState({fetchingMessages: true}, () => {
|
||||||
topic.getMessagesPage(MESSAGES_PAGE)
|
topic.getMessagesPage(MESSAGES_PAGE)
|
||||||
.then(() => this.setState({fetchingMessages: false}))
|
.catch((err) => this.props.onError(err.message, 'err'))
|
||||||
.catch((err) => {
|
.finally(() => this.setState({fetchingMessages: false}));
|
||||||
this.setState({fetchingMessages: false});
|
|
||||||
this.props.onError(err.message, 'err');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newState;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleDescChange(desc) {
|
handleDescChange(desc) {
|
||||||
|
|||||||
+19
-25
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
+13
-6
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