[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 log from '../../utils/log';
|
||||||
import updateMessages from './updateMessages';
|
import updateMessages from './updateMessages';
|
||||||
|
|
||||||
|
@ -22,10 +20,8 @@ export default function loadMessagesForRoom(args) {
|
||||||
const data = await load.call(this, args);
|
const data = await load.call(this, args);
|
||||||
|
|
||||||
if (data && data.length) {
|
if (data && data.length) {
|
||||||
InteractionManager.runAfterInteractions(async() => {
|
|
||||||
await updateMessages({ rid: args.rid, update: data });
|
await updateMessages({ rid: args.rid, update: data });
|
||||||
return resolve(data);
|
return resolve(data);
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
return resolve([]);
|
return resolve([]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { InteractionManager } from 'react-native';
|
|
||||||
|
|
||||||
import database from '../database';
|
import database from '../database';
|
||||||
import log from '../../utils/log';
|
import log from '../../utils/log';
|
||||||
import updateMessages from './updateMessages';
|
import updateMessages from './updateMessages';
|
||||||
|
@ -35,9 +33,7 @@ export default function loadMissedMessages(args) {
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
const { updated, deleted } = data;
|
const { updated, deleted } = data;
|
||||||
InteractionManager.runAfterInteractions(async() => {
|
|
||||||
await updateMessages({ rid: args.rid, update: updated, remove: deleted });
|
await updateMessages({ rid: args.rid, update: updated, remove: deleted });
|
||||||
});
|
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import database from '../database';
|
import database from '../database';
|
||||||
import log from '../../utils/log';
|
import log from '../../utils/log';
|
||||||
|
|
||||||
export default async function readMessages(rid, lastOpen) {
|
export default async function readMessages(rid, ls, updateLastOpen = false) {
|
||||||
try {
|
try {
|
||||||
const db = database.active;
|
const db = database.active;
|
||||||
const subscription = await db.collections.get('subscriptions').find(rid);
|
const subscription = await db.collections.get('subscriptions').find(rid);
|
||||||
|
@ -17,8 +17,10 @@ export default async function readMessages(rid, lastOpen) {
|
||||||
s.unread = 0;
|
s.unread = 0;
|
||||||
s.userMentions = 0;
|
s.userMentions = 0;
|
||||||
s.groupMentions = 0;
|
s.groupMentions = 0;
|
||||||
s.ls = lastOpen;
|
s.ls = ls;
|
||||||
s.lastOpen = lastOpen;
|
if (updateLastOpen) {
|
||||||
|
s.lastOpen = ls;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
|
|
@ -341,7 +341,7 @@ class RoomView extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
this.setLastOpen(null);
|
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();
|
this.sub.subscribe();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue