From 42c69f0c06ccfa3eca0d936e0b61a338337aef08 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 20 Oct 2021 13:35:28 -0300 Subject: [PATCH] [FIX] Make sure messages are loading properly (#3227) * [FIX] Conditional to compare the server version and filter or not the system messages * instead of lowerThanOrEqualTo using lowerThan * To do a reactive message list * minor tweaks Co-authored-by: Gerzon Z Co-authored-by: Diego Mello --- app/views/RoomView/List/index.js | 15 ++++++++++++--- app/views/RoomView/index.js | 5 ++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/views/RoomView/List/index.js b/app/views/RoomView/List/index.js index c32490ba..0db6c8b6 100644 --- a/app/views/RoomView/List/index.js +++ b/app/views/RoomView/List/index.js @@ -14,6 +14,7 @@ import { animateNextTransition } from '../../../utils/layoutAnimation'; import ActivityIndicator from '../../../containers/ActivityIndicator'; import { themes } from '../../../constants/colors'; import debounce from '../../../utils/debounce'; +import { compareServerVersion, methods } from '../../../lib/utils'; import List from './List'; import NavBottomFAB from './NavBottomFAB'; @@ -43,7 +44,8 @@ class ListContainer extends React.Component { tunread: PropTypes.array, ignored: PropTypes.array, navigation: PropTypes.object, - showMessageInMainThread: PropTypes.bool + showMessageInMainThread: PropTypes.bool, + serverVersion: PropTypes.string }; constructor(props) { @@ -131,7 +133,7 @@ class ListContainer extends React.Component { query = async () => { this.count += QUERY_SIZE; - const { rid, tmid, showMessageInMainThread } = this.props; + const { rid, tmid, showMessageInMainThread, serverVersion } = this.props; const db = database.active; // handle servers with version < 3.0.0 @@ -172,7 +174,14 @@ class ListContainer extends React.Component { if (tmid && this.thread) { messages = [...messages, this.thread]; } - messages = messages.filter(m => !m.t || !hideSystemMessages?.includes(m.t)); + + /** + * Since 3.16.0 server version, the backend don't response with messages if + * hide system message is enabled + */ + if (compareServerVersion(serverVersion, '3.16.0', methods.lowerThan) || hideSystemMessages.length) { + messages = messages.filter(m => !m.t || !hideSystemMessages?.includes(m.t)); + } if (this.mounted) { this.setState({ messages }, () => this.update()); diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index a94af5f4..dab69746 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -120,6 +120,7 @@ class RoomView extends React.Component { Message_Read_Receipt_Enabled: PropTypes.bool, Hide_System_Messages: PropTypes.array, baseUrl: PropTypes.string, + serverVersion: PropTypes.string, customEmojis: PropTypes.object, isMasterDetail: PropTypes.bool, theme: PropTypes.string, @@ -1154,7 +1155,7 @@ class RoomView extends React.Component { render() { console.count(`${this.constructor.name}.render calls`); const { room, reactionsModalVisible, selectedMessage, loading, reacting, showingBlockingLoader } = this.state; - const { user, baseUrl, theme, navigation, Hide_System_Messages, width, height } = this.props; + const { user, baseUrl, theme, navigation, Hide_System_Messages, width, height, serverVersion } = this.props; const { rid, t, sysMes, bannerClosed, announcement } = room; return ( @@ -1182,6 +1183,7 @@ class RoomView extends React.Component { navigation={navigation} hideSystemMessages={Array.isArray(sysMes) ? sysMes : Hide_System_Messages} showMessageInMainThread={user.showMessageInMainThread} + serverVersion={serverVersion} /> {this.renderFooter()} {this.renderActions()} @@ -1220,6 +1222,7 @@ const mapStateToProps = state => ({ Message_TimeFormat: state.settings.Message_TimeFormat, customEmojis: state.customEmojis, baseUrl: state.server.server, + serverVersion: state.server.version, Message_Read_Receipt_Enabled: state.settings.Message_Read_Receipt_Enabled, Hide_System_Messages: state.settings.Hide_System_Messages });