Fix load more

This commit is contained in:
Diego Mello 2022-11-25 15:56:13 -03:00
parent 537cd0032e
commit 1ea3916e94
2 changed files with 39 additions and 41 deletions

View File

@ -12,7 +12,6 @@ export type MessageType =
| 'jitsi_call_started' | 'jitsi_call_started'
| 'discussion-created' | 'discussion-created'
| 'e2e' | 'e2e'
| 'load_more'
| 'rm' | 'rm'
| 'uj' | 'uj'
| MessageTypeLoad | MessageTypeLoad

View File

@ -19,7 +19,7 @@ import NavBottomFAB from './NavBottomFAB';
import { loadMissedMessages, loadThreadMessages } from '../../../lib/methods'; import { loadMissedMessages, loadThreadMessages } from '../../../lib/methods';
import { Services } from '../../../lib/services'; import { Services } from '../../../lib/services';
import { TSupportedThemes, withTheme } from '../../../theme'; import { TSupportedThemes, withTheme } from '../../../theme';
import { themes } from '../../../lib/constants'; import { MESSAGE_TYPE_ANY_LOAD, themes } from '../../../lib/constants';
const QUERY_SIZE = 50; const QUERY_SIZE = 50;
@ -186,37 +186,44 @@ class ListContainer extends React.Component<IListContainerProps, IListContainerS
this.unsubscribeMessages(); this.unsubscribeMessages();
this.messagesSubscription = this.messagesObservable?.subscribe(messages => { this.messagesSubscription = this.messagesObservable?.subscribe(messages => {
// @ts-ignore is this enough cols? // @ts-ignore is this enough cols?
messages = messages.map(m => ({ messages = messages.map(m => {
id: m.id, if (MESSAGE_TYPE_ANY_LOAD.includes(m.t)) {
msg: m.msg, return m;
ts: m.ts, }
status: m.status,
attachments: m.attachments, return {
urls: m.urls, id: m.id,
reactions: m.reactions, _id: m._id,
t: m.t, msg: m.msg,
avatar: m.avatar, ts: m.ts,
emoji: m.emoji, status: m.status,
u: m.u, attachments: m.attachments,
alias: m.alias, urls: m.urls,
editedBy: m.editedBy, reactions: m.reactions,
role: m.role, t: m.t,
drid: m.drid, avatar: m.avatar,
dcount: m.dcount, emoji: m.emoji,
dlm: m.dlm, u: m.u,
tmid: m.tmid, alias: m.alias,
tcount: m.tcount, editedBy: m.editedBy,
tlm: m.tlm, role: m.role,
tmsg: m.tmsg, drid: m.drid,
mentions: m.mentions, dcount: m.dcount,
channels: m.channels, dlm: m.dlm,
unread: m.unread, tmid: m.tmid,
blocks: m.blocks, tcount: m.tcount,
autoTranslate: m.autoTranslate, tlm: m.tlm,
replies: m.replies, tmsg: m.tmsg,
md: m.md, mentions: m.mentions,
comment: m.comment channels: m.channels,
})); unread: m.unread,
blocks: m.blocks,
autoTranslate: m.autoTranslate,
replies: m.replies,
md: m.md,
comment: m.comment
};
});
if (tmid && this.thread) { if (tmid && this.thread) {
messages = [...messages, this.thread]; messages = [...messages, this.thread];
} }
@ -233,7 +240,6 @@ class ListContainer extends React.Component<IListContainerProps, IListContainerS
// if (this.animated) { // if (this.animated) {
// animateNextTransition(); // animateNextTransition();
// } // }
// this.setState({ messages }, () => this.update());
this.setState({ messages }); this.setState({ messages });
} else { } else {
// @ts-ignore // @ts-ignore
@ -284,13 +290,6 @@ class ListContainer extends React.Component<IListContainerProps, IListContainerS
this.setState({ refreshing: false }); this.setState({ refreshing: false });
}); });
update = () => {
if (this.animated) {
animateNextTransition();
}
// this.forceUpdate();
};
unsubscribeMessages = () => { unsubscribeMessages = () => {
if (this.messagesSubscription && this.messagesSubscription.unsubscribe) { if (this.messagesSubscription && this.messagesSubscription.unsubscribe) {
this.messagesSubscription.unsubscribe(); this.messagesSubscription.unsubscribe();