verdnatura-chat/app/lib/methods/readMessages.js

24 lines
623 B
JavaScript

import database from '../realm';
import log from '../../utils/log';
export default async function readMessages(rid) {
const ls = new Date();
try {
// RC 0.61.0
const data = await this.sdk.post('subscriptions.read', { rid });
const [subscription] = database.objects('subscriptions').filtered('rid = $0', rid);
database.write(() => {
subscription.open = true;
subscription.alert = false;
subscription.unread = 0;
subscription.userMentions = 0;
subscription.groupMentions = 0;
subscription.ls = ls;
subscription.lastOpen = ls;
});
return data;
} catch (e) {
log('readMessages', e);
}
}