[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 <gerzonc@icloud.com> Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
parent
1889918875
commit
42c69f0c06
|
@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue