[FIX] Load messages (#1910)
* Create updateLastOpen param on readMessages * Remove InteractionManager from load messages
This commit is contained in:
parent
475ccbd9c7
commit
3437b9039f
|
@ -1,5 +1,3 @@
|
|||
import { InteractionManager } from 'react-native';
|
||||
|
||||
import log from '../../utils/log';
|
||||
import updateMessages from './updateMessages';
|
||||
|
||||
|
@ -22,10 +20,8 @@ export default function loadMessagesForRoom(args) {
|
|||
const data = await load.call(this, args);
|
||||
|
||||
if (data && data.length) {
|
||||
InteractionManager.runAfterInteractions(async() => {
|
||||
await updateMessages({ rid: args.rid, update: data });
|
||||
return resolve(data);
|
||||
});
|
||||
} else {
|
||||
return resolve([]);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { InteractionManager } from 'react-native';
|
||||
|
||||
import database from '../database';
|
||||
import log from '../../utils/log';
|
||||
import updateMessages from './updateMessages';
|
||||
|
@ -35,9 +33,7 @@ export default function loadMissedMessages(args) {
|
|||
|
||||
if (data) {
|
||||
const { updated, deleted } = data;
|
||||
InteractionManager.runAfterInteractions(async() => {
|
||||
await updateMessages({ rid: args.rid, update: updated, remove: deleted });
|
||||
});
|
||||
}
|
||||
resolve();
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import database from '../database';
|
||||
import log from '../../utils/log';
|
||||
|
||||
export default async function readMessages(rid, lastOpen) {
|
||||
export default async function readMessages(rid, ls, updateLastOpen = false) {
|
||||
try {
|
||||
const db = database.active;
|
||||
const subscription = await db.collections.get('subscriptions').find(rid);
|
||||
|
@ -17,8 +17,10 @@ export default async function readMessages(rid, lastOpen) {
|
|||
s.unread = 0;
|
||||
s.userMentions = 0;
|
||||
s.groupMentions = 0;
|
||||
s.ls = lastOpen;
|
||||
s.lastOpen = lastOpen;
|
||||
s.ls = ls;
|
||||
if (updateLastOpen) {
|
||||
s.lastOpen = ls;
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
// Do nothing
|
||||
|
|
|
@ -341,7 +341,7 @@ class RoomView extends React.Component {
|
|||
} else {
|
||||
this.setLastOpen(null);
|
||||
}
|
||||
RocketChat.readMessages(room.rid, newLastOpen).catch(e => console.log(e));
|
||||
RocketChat.readMessages(room.rid, newLastOpen, true).catch(e => console.log(e));
|
||||
this.sub.subscribe();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue