[CHORE] Use shortcut syntax for get collections (#2932)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Gung Wah 2021-02-27 00:25:51 +08:00 committed by GitHub
parent a1c9fdfdb9
commit 98890df773
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 114 additions and 114 deletions

View File

@ -52,8 +52,8 @@ class AvatarContainer extends React.Component {
init = async() => { init = async() => {
const db = database.active; const db = database.active;
const usersCollection = db.collections.get('users'); const usersCollection = db.get('users');
const subsCollection = db.collections.get('subscriptions'); const subsCollection = db.get('subscriptions');
let record; let record;
try { try {

View File

@ -95,7 +95,7 @@ class EmojiPicker extends Component {
// eslint-disable-next-line react/sort-comp // eslint-disable-next-line react/sort-comp
_addFrequentlyUsed = protectedFunction(async(emoji) => { _addFrequentlyUsed = protectedFunction(async(emoji) => {
const db = database.active; const db = database.active;
const freqEmojiCollection = db.collections.get('frequently_used_emojis'); const freqEmojiCollection = db.get('frequently_used_emojis');
let freqEmojiRecord; let freqEmojiRecord;
try { try {
freqEmojiRecord = await freqEmojiCollection.find(emoji.content); freqEmojiRecord = await freqEmojiCollection.find(emoji.content);
@ -120,7 +120,7 @@ class EmojiPicker extends Component {
updateFrequentlyUsed = async() => { updateFrequentlyUsed = async() => {
const db = database.active; const db = database.active;
const frequentlyUsedRecords = await db.collections.get('frequently_used_emojis').query().fetch(); const frequentlyUsedRecords = await db.get('frequently_used_emojis').query().fetch();
let frequentlyUsed = orderBy(frequentlyUsedRecords, ['count'], ['desc']); let frequentlyUsed = orderBy(frequentlyUsedRecords, ['count'], ['desc']);
frequentlyUsed = frequentlyUsed.map((item) => { frequentlyUsed = frequentlyUsed.map((item) => {
if (item.isCustom) { if (item.isCustom) {

View File

@ -96,7 +96,7 @@ const Header = React.memo(({
const setEmojis = async() => { const setEmojis = async() => {
try { try {
const db = database.active; const db = database.active;
const freqEmojiCollection = db.collections.get('frequently_used_emojis'); const freqEmojiCollection = db.get('frequently_used_emojis');
let freqEmojis = await freqEmojiCollection.query().fetch(); let freqEmojis = await freqEmojiCollection.query().fetch();
const isLandscape = width > height; const isLandscape = width > height;

View File

@ -145,7 +145,7 @@ const MessageActions = React.memo(forwardRef(({
const db = database.active; const db = database.active;
const result = await RocketChat.markAsUnread({ messageId }); const result = await RocketChat.markAsUnread({ messageId });
if (result.success) { if (result.success) {
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
const subRecord = await subCollection.find(rid); const subRecord = await subCollection.find(rid);
await db.action(async() => { await db.action(async() => {
try { try {

View File

@ -190,8 +190,8 @@ class MessageBox extends Component {
} = this.props; } = this.props;
let msg; let msg;
try { try {
const threadsCollection = db.collections.get('threads'); const threadsCollection = db.get('threads');
const subsCollection = db.collections.get('subscriptions'); const subsCollection = db.get('subscriptions');
try { try {
this.room = await subsCollection.find(rid); this.room = await subsCollection.find(rid);
} catch (error) { } catch (error) {
@ -364,7 +364,7 @@ class MessageBox extends Component {
const slashCommand = text.match(/^\/([a-z0-9._-]+) (.+)/im); const slashCommand = text.match(/^\/([a-z0-9._-]+) (.+)/im);
if (slashCommand) { if (slashCommand) {
const [, name, params] = slashCommand; const [, name, params] = slashCommand;
const commandsCollection = db.collections.get('slash_commands'); const commandsCollection = db.get('slash_commands');
try { try {
const command = await commandsCollection.find(name); const command = await commandsCollection.find(name);
if (command.providesPreview) { if (command.providesPreview) {
@ -505,7 +505,7 @@ class MessageBox extends Component {
getEmojis = debounce(async(keyword) => { getEmojis = debounce(async(keyword) => {
const db = database.active; const db = database.active;
if (keyword) { if (keyword) {
const customEmojisCollection = db.collections.get('custom_emojis'); const customEmojisCollection = db.get('custom_emojis');
const likeString = sanitizeLikeString(keyword); const likeString = sanitizeLikeString(keyword);
let customEmojis = await customEmojisCollection.query( let customEmojis = await customEmojisCollection.query(
Q.where('name', Q.like(`${ likeString }%`)) Q.where('name', Q.like(`${ likeString }%`))
@ -519,7 +519,7 @@ class MessageBox extends Component {
getSlashCommands = debounce(async(keyword) => { getSlashCommands = debounce(async(keyword) => {
const db = database.active; const db = database.active;
const commandsCollection = db.collections.get('slash_commands'); const commandsCollection = db.get('slash_commands');
const likeString = sanitizeLikeString(keyword); const likeString = sanitizeLikeString(keyword);
const commands = await commandsCollection.query( const commands = await commandsCollection.query(
Q.where('id', Q.like(`${ likeString }%`)) Q.where('id', Q.like(`${ likeString }%`))
@ -751,7 +751,7 @@ class MessageBox extends Component {
// Slash command // Slash command
if (message[0] === MENTIONS_TRACKING_TYPE_COMMANDS) { if (message[0] === MENTIONS_TRACKING_TYPE_COMMANDS) {
const db = database.active; const db = database.active;
const commandsCollection = db.collections.get('slash_commands'); const commandsCollection = db.get('slash_commands');
const command = message.replace(/ .*/, '').slice(1); const command = message.replace(/ .*/, '').slice(1);
const likeString = sanitizeLikeString(command); const likeString = sanitizeLikeString(command);
const slashCommand = await commandsCollection.query( const slashCommand = await commandsCollection.query(

View File

@ -19,8 +19,8 @@ const MessageErrorActions = forwardRef(({ tmid }, ref) => {
try { try {
const db = database.active; const db = database.active;
const deleteBatch = []; const deleteBatch = [];
const msgCollection = db.collections.get('messages'); const msgCollection = db.get('messages');
const threadCollection = db.collections.get('threads'); const threadCollection = db.get('threads');
// Delete the object (it can be Message or ThreadMessage instance) // Delete the object (it can be Message or ThreadMessage instance)
deleteBatch.push(message.prepareDestroyPermanently()); deleteBatch.push(message.prepareDestroyPermanently());

View File

@ -229,9 +229,9 @@ class Encryption {
decryptPendingMessages = async(roomId) => { decryptPendingMessages = async(roomId) => {
const db = database.active; const db = database.active;
const messagesCollection = db.collections.get('messages'); const messagesCollection = db.get('messages');
const threadsCollection = db.collections.get('threads'); const threadsCollection = db.get('threads');
const threadMessagesCollection = db.collections.get('thread_messages'); const threadMessagesCollection = db.get('thread_messages');
// e2e status is null or 'pending' and message type is 'e2e' // e2e status is null or 'pending' and message type is 'e2e'
const whereClause = [ const whereClause = [
@ -286,7 +286,7 @@ class Encryption {
// after initialize the encryption client // after initialize the encryption client
decryptPendingSubscriptions = async() => { decryptPendingSubscriptions = async() => {
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
try { try {
// Find all rooms that can have a lastMessage encrypted // Find all rooms that can have a lastMessage encrypted
// If we select only encrypted rooms we can miss some room that changed their encrypted status // If we select only encrypted rooms we can miss some room that changed their encrypted status
@ -347,7 +347,7 @@ class Encryption {
const { rid } = subscription; const { rid } = subscription;
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
let subRecord; let subRecord;
try { try {
@ -400,7 +400,7 @@ class Encryption {
encryptMessage = async(message) => { encryptMessage = async(message) => {
const { rid } = message; const { rid } = message;
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
try { try {
// Find the subscription // Find the subscription

View File

@ -49,7 +49,7 @@ export default class EncryptionRoom {
} }
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
try { try {
// Find the subscription // Find the subscription
const subscription = await subCollection.find(this.roomId); const subscription = await subCollection.find(this.roomId);

View File

@ -57,7 +57,7 @@ async function open({ type, rid, name }) {
export default async function canOpenRoom({ rid, path, isCall }) { export default async function canOpenRoom({ rid, path, isCall }) {
try { try {
const db = database.active; const db = database.active;
const subsCollection = db.collections.get('subscriptions'); const subsCollection = db.get('subscriptions');
if (isCall && !rid) { if (isCall && !rid) {
// Extract rid from a Jitsi URL // Extract rid from a Jitsi URL

View File

@ -13,7 +13,7 @@ export async function setEnterpriseModules() {
try { try {
const { server: serverId } = reduxStore.getState().server; const { server: serverId } = reduxStore.getState().server;
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
let server; let server;
try { try {
server = await serversCollection.find(serverId); server = await serversCollection.find(serverId);
@ -39,7 +39,7 @@ export function getEnterpriseModules() {
const enterpriseModules = await this.methodCallWrapper('license:getModules'); const enterpriseModules = await this.methodCallWrapper('license:getModules');
if (enterpriseModules) { if (enterpriseModules) {
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
const server = await serversCollection.find(serverId); const server = await serversCollection.find(serverId);
await serversDB.action(async() => { await serversDB.action(async() => {
await server.update((s) => { await server.update((s) => {

View File

@ -20,7 +20,7 @@ const updateEmojis = async({ update = [], remove = [], allRecords }) => {
return; return;
} }
const db = database.active; const db = database.active;
const emojisCollection = db.collections.get('custom_emojis'); const emojisCollection = db.get('custom_emojis');
let emojisToCreate = []; let emojisToCreate = [];
let emojisToUpdate = []; let emojisToUpdate = [];
let emojisToDelete = []; let emojisToDelete = [];
@ -62,7 +62,7 @@ const updateEmojis = async({ update = [], remove = [], allRecords }) => {
export async function setCustomEmojis() { export async function setCustomEmojis() {
const db = database.active; const db = database.active;
const emojisCollection = db.collections.get('custom_emojis'); const emojisCollection = db.get('custom_emojis');
const allEmojis = await emojisCollection.query().fetch(); const allEmojis = await emojisCollection.query().fetch();
const parsed = allEmojis.reduce((ret, item) => { const parsed = allEmojis.reduce((ret, item) => {
ret[item.name] = { ret[item.name] = {
@ -85,7 +85,7 @@ export function getCustomEmojis() {
try { try {
const serverVersion = reduxStore.getState().server.version; const serverVersion = reduxStore.getState().server.version;
const db = database.active; const db = database.active;
const emojisCollection = db.collections.get('custom_emojis'); const emojisCollection = db.get('custom_emojis');
const allRecords = await emojisCollection.query().fetch(); const allRecords = await emojisCollection.query().fetch();
const updatedSince = await getUpdatedSince(allRecords); const updatedSince = await getUpdatedSince(allRecords);

View File

@ -69,7 +69,7 @@ const updatePermissions = async({ update = [], remove = [], allRecords }) => {
return; return;
} }
const db = database.active; const db = database.active;
const permissionsCollection = db.collections.get('permissions'); const permissionsCollection = db.get('permissions');
// filter permissions // filter permissions
let permissionsToCreate = []; let permissionsToCreate = [];
@ -119,7 +119,7 @@ export function getPermissions() {
try { try {
const serverVersion = reduxStore.getState().server.version; const serverVersion = reduxStore.getState().server.version;
const db = database.active; const db = database.active;
const permissionsCollection = db.collections.get('permissions'); const permissionsCollection = db.get('permissions');
const allRecords = await permissionsCollection.query().fetch(); const allRecords = await permissionsCollection.query().fetch();
// if server version is lower than 0.73.0, fetches from old api // if server version is lower than 0.73.0, fetches from old api

View File

@ -19,7 +19,7 @@ export default function() {
if (roles && roles.length) { if (roles && roles.length) {
await db.action(async() => { await db.action(async() => {
const rolesCollections = db.collections.get('roles'); const rolesCollections = db.get('roles');
const allRolesRecords = await rolesCollections.query().fetch(); const allRolesRecords = await rolesCollections.query().fetch();
// filter roles // filter roles

View File

@ -44,7 +44,7 @@ const loginSettings = [
const serverInfoUpdate = async(serverInfo, iconSetting) => { const serverInfoUpdate = async(serverInfo, iconSetting) => {
const serversDB = database.servers; const serversDB = database.servers;
const serverId = reduxStore.getState().server.server; const serverId = reduxStore.getState().server.server;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
const server = await serversCollection.find(serverId); const server = await serversCollection.find(serverId);
let info = serverInfo.reduce((allSettings, setting) => { let info = serverInfo.reduce((allSettings, setting) => {
@ -118,7 +118,7 @@ export async function getLoginSettings({ server }) {
export async function setSettings() { export async function setSettings() {
const db = database.active; const db = database.active;
const settingsCollection = db.collections.get('settings'); const settingsCollection = db.get('settings');
const settingsRecords = await settingsCollection.query().fetch(); const settingsRecords = await settingsCollection.query().fetch();
const parsed = Object.values(settingsRecords).map(item => ({ const parsed = Object.values(settingsRecords).map(item => ({
_id: item.id, _id: item.id,
@ -157,7 +157,7 @@ export default async function() {
} }
await db.action(async() => { await db.action(async() => {
const settingsCollection = db.collections.get('settings'); const settingsCollection = db.get('settings');
const allSettingsRecords = await settingsCollection const allSettingsRecords = await settingsCollection
.query(Q.where('id', Q.oneOf(filteredSettingsIds))) .query(Q.where('id', Q.oneOf(filteredSettingsIds)))
.fetch(); .fetch();

View File

@ -20,7 +20,7 @@ export default function() {
if (commands && commands.length) { if (commands && commands.length) {
await db.action(async() => { await db.action(async() => {
const slashCommandsCollection = db.collections.get('slash_commands'); const slashCommandsCollection = db.get('slash_commands');
const allSlashCommandsRecords = await slashCommandsCollection.query().fetch(); const allSlashCommandsRecords = await slashCommandsCollection.query().fetch();
// filter slash commands // filter slash commands

View File

@ -72,7 +72,7 @@ export default async function getUsersPresence() {
ids = []; ids = [];
const db = database.active; const db = database.active;
const userCollection = db.collections.get('users'); const userCollection = db.get('users');
users.forEach(async(user) => { users.forEach(async(user) => {
try { try {
const userRecord = await userCollection.find(user._id); const userRecord = await userCollection.find(user._id);

View File

@ -5,7 +5,7 @@ import database from '../../database';
export default async(subscriptions = [], rooms = []) => { export default async(subscriptions = [], rooms = []) => {
try { try {
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
const roomIds = rooms.filter(r => !subscriptions.find(s => s.rid === r._id)).map(r => r._id); const roomIds = rooms.filter(r => !subscriptions.find(s => s.rid === r._id)).map(r => r._id);
let existingSubs = await subCollection.query(Q.where('rid', Q.oneOf(roomIds))).fetch(); let existingSubs = await subCollection.query(Q.where('rid', Q.oneOf(roomIds))).fetch();

View File

@ -5,7 +5,7 @@ import updateMessages from './updateMessages';
const getLastUpdate = async(rid) => { const getLastUpdate = async(rid) => {
try { try {
const db = database.active; const db = database.active;
const subsCollection = db.collections.get('subscriptions'); const subsCollection = db.get('subscriptions');
const sub = await subsCollection.find(rid); const sub = await subsCollection.find(rid);
return sub.lastOpen.toISOString(); return sub.lastOpen.toISOString();
} catch (e) { } catch (e) {

View File

@ -33,7 +33,7 @@ export default function loadThreadMessages({ tmid, rid, offset = 0 }) {
data = data.map(m => buildMessage(m)); data = data.map(m => buildMessage(m));
data = await Encryption.decryptMessages(data); data = await Encryption.decryptMessages(data);
const db = database.active; const db = database.active;
const threadMessagesCollection = db.collections.get('thread_messages'); const threadMessagesCollection = db.get('thread_messages');
const allThreadMessagesRecords = await threadMessagesCollection.query(Q.where('rid', tmid)).fetch(); const allThreadMessagesRecords = await threadMessagesCollection.query(Q.where('rid', tmid)).fetch();
let threadMessagesToCreate = data.filter(i1 => !allThreadMessagesRecords.find(i2 => i1._id === i2.id)); let threadMessagesToCreate = data.filter(i1 => !allThreadMessagesRecords.find(i2 => i1._id === i2.id));
let threadMessagesToUpdate = allThreadMessagesRecords.filter(i1 => data.find(i2 => i1.id === i2._id)); let threadMessagesToUpdate = allThreadMessagesRecords.filter(i1 => data.find(i2 => i1.id === i2._id));

View File

@ -42,12 +42,12 @@ async function removeServerData({ server }) {
const serversDB = database.servers; const serversDB = database.servers;
const userId = await UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`); const userId = await UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
const usersCollection = serversDB.collections.get('users'); const usersCollection = serversDB.get('users');
if (userId) { if (userId) {
const userRecord = await usersCollection.find(userId); const userRecord = await usersCollection.find(userId);
batch.push(userRecord.prepareDestroyPermanently()); batch.push(userRecord.prepareDestroyPermanently());
} }
const serverCollection = serversDB.collections.get('servers'); const serverCollection = serversDB.get('servers');
const serverRecord = await serverCollection.find(server); const serverRecord = await serverCollection.find(server);
batch.push(serverRecord.prepareDestroyPermanently()); batch.push(serverRecord.prepareDestroyPermanently());

View File

@ -4,7 +4,7 @@ import log from '../../utils/log';
export default async function readMessages(rid, ls, updateLastOpen = false) { 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.get('subscriptions').find(rid);
// RC 0.61.0 // RC 0.61.0
await this.sdk.post('subscriptions.read', { rid }); await this.sdk.post('subscriptions.read', { rid });

View File

@ -40,7 +40,7 @@ export function sendFileMessage(rid, fileInfo, tmid, server, user) {
fileInfo.rid = rid; fileInfo.rid = rid;
const db = database.active; const db = database.active;
const uploadsCollection = db.collections.get('uploads'); const uploadsCollection = db.get('uploads');
let uploadRecord; let uploadRecord;
try { try {
uploadRecord = await uploadsCollection.find(fileInfo.path); uploadRecord = await uploadsCollection.find(fileInfo.path);

View File

@ -9,8 +9,8 @@ import { E2E_MESSAGE_TYPE, E2E_STATUS } from '../encryption/constants';
const changeMessageStatus = async(id, tmid, status, message) => { const changeMessageStatus = async(id, tmid, status, message) => {
const db = database.active; const db = database.active;
const msgCollection = db.collections.get('messages'); const msgCollection = db.get('messages');
const threadMessagesCollection = db.collections.get('thread_messages'); const threadMessagesCollection = db.get('thread_messages');
const successBatch = []; const successBatch = [];
const messageRecord = await msgCollection.find(id); const messageRecord = await msgCollection.find(id);
successBatch.push( successBatch.push(
@ -89,10 +89,10 @@ export async function resendMessage(message, tmid) {
export default async function(rid, msg, tmid, user, tshow) { export default async function(rid, msg, tmid, user, tshow) {
try { try {
const db = database.active; const db = database.active;
const subsCollection = db.collections.get('subscriptions'); const subsCollection = db.get('subscriptions');
const msgCollection = db.collections.get('messages'); const msgCollection = db.get('messages');
const threadCollection = db.collections.get('threads'); const threadCollection = db.get('threads');
const threadMessagesCollection = db.collections.get('thread_messages'); const threadMessagesCollection = db.get('thread_messages');
const messageId = random(17); const messageId = random(17);
const batch = []; const batch = [];

View File

@ -109,9 +109,9 @@ export default class RoomSubscription {
try { try {
const { _id } = ddpMessage.fields.args[0]; const { _id } = ddpMessage.fields.args[0];
const db = database.active; const db = database.active;
const msgCollection = db.collections.get('messages'); const msgCollection = db.get('messages');
const threadsCollection = db.collections.get('threads'); const threadsCollection = db.get('threads');
const threadMessagesCollection = db.collections.get('thread_messages'); const threadMessagesCollection = db.get('thread_messages');
let deleteMessage; let deleteMessage;
let deleteThread; let deleteThread;
let deleteThreadMessage; let deleteThreadMessage;
@ -163,9 +163,9 @@ export default class RoomSubscription {
} }
const db = database.active; const db = database.active;
const msgCollection = db.collections.get('messages'); const msgCollection = db.get('messages');
const threadsCollection = db.collections.get('threads'); const threadsCollection = db.get('threads');
const threadMessagesCollection = db.collections.get('thread_messages'); const threadMessagesCollection = db.get('thread_messages');
// Decrypt the message if necessary // Decrypt the message if necessary
message = await Encryption.decryptMessage(message); message = await Encryption.decryptMessage(message);

View File

@ -32,8 +32,8 @@ const WINDOW_TIME = 500;
const createOrUpdateSubscription = async(subscription, room) => { const createOrUpdateSubscription = async(subscription, room) => {
try { try {
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
const roomsCollection = db.collections.get('rooms'); const roomsCollection = db.get('rooms');
if (!subscription) { if (!subscription) {
try { try {
@ -185,7 +185,7 @@ const createOrUpdateSubscription = async(subscription, room) => {
const { rooms } = store.getState().room; const { rooms } = store.getState().room;
if (tmp.lastMessage && !rooms.includes(tmp.rid)) { if (tmp.lastMessage && !rooms.includes(tmp.rid)) {
const lastMessage = buildMessage(tmp.lastMessage); const lastMessage = buildMessage(tmp.lastMessage);
const messagesCollection = db.collections.get('messages'); const messagesCollection = db.get('messages');
let messageRecord; let messageRecord;
try { try {
messageRecord = await messagesCollection.find(lastMessage._id); messageRecord = await messagesCollection.find(lastMessage._id);
@ -281,7 +281,7 @@ export default function subscribeRooms() {
if (/subscriptions/.test(ev)) { if (/subscriptions/.test(ev)) {
if (type === 'removed') { if (type === 'removed') {
try { try {
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
const sub = await subCollection.find(data.rid); const sub = await subCollection.find(data.rid);
const messages = await sub.messages.fetch(); const messages = await sub.messages.fetch();
const threads = await sub.threads.fetch(); const threads = await sub.threads.fetch();
@ -335,7 +335,7 @@ export default function subscribeRooms() {
} }
}; };
try { try {
const msgCollection = db.collections.get('messages'); const msgCollection = db.get('messages');
await db.action(async() => { await db.action(async() => {
await msgCollection.create(protectedFunction((m) => { await msgCollection.create(protectedFunction((m) => {
m._raw = sanitizedRaw({ id: message._id }, msgCollection.schema); m._raw = sanitizedRaw({ id: message._id }, msgCollection.schema);

View File

@ -16,7 +16,7 @@ export default function updateMessages({ rid, update = [], remove = [] }) {
return db.action(async() => { return db.action(async() => {
// Decrypt these messages // Decrypt these messages
update = await Encryption.decryptMessages(update); update = await Encryption.decryptMessages(update);
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
let sub; let sub;
try { try {
sub = await subCollection.find(rid); sub = await subCollection.find(rid);
@ -26,9 +26,9 @@ export default function updateMessages({ rid, update = [], remove = [] }) {
} }
const messagesIds = [...update.map(m => m._id), ...remove.map(m => m._id)]; const messagesIds = [...update.map(m => m._id), ...remove.map(m => m._id)];
const msgCollection = db.collections.get('messages'); const msgCollection = db.get('messages');
const threadCollection = db.collections.get('threads'); const threadCollection = db.get('threads');
const threadMessagesCollection = db.collections.get('thread_messages'); const threadMessagesCollection = db.get('thread_messages');
const allMessagesRecords = await msgCollection const allMessagesRecords = await msgCollection
.query(Q.where('rid', rid), Q.where('id', Q.oneOf(messagesIds))) .query(Q.where('rid', rid), Q.where('id', Q.oneOf(messagesIds)))
.fetch(); .fetch();

View File

@ -275,7 +275,7 @@ const RocketChat = {
} else if (/updateAvatar/.test(eventName)) { } else if (/updateAvatar/.test(eventName)) {
const { username, etag } = ddpMessage.fields.args[0]; const { username, etag } = ddpMessage.fields.args[0];
const db = database.active; const db = database.active;
const userCollection = db.collections.get('users'); const userCollection = db.get('users');
try { try {
const [userRecord] = await userCollection.query(Q.where('username', Q.eq(username))).fetch(); const [userRecord] = await userCollection.query(Q.where('username', Q.eq(username))).fetch();
await db.action(async() => { await db.action(async() => {
@ -289,7 +289,7 @@ const RocketChat = {
} else if (/Users:NameChanged/.test(eventName)) { } else if (/Users:NameChanged/.test(eventName)) {
const userNameChanged = ddpMessage.fields.args[0]; const userNameChanged = ddpMessage.fields.args[0];
const db = database.active; const db = database.active;
const userCollection = db.collections.get('users'); const userCollection = db.get('users');
try { try {
const userRecord = await userCollection.find(userNameChanged._id); const userRecord = await userCollection.find(userNameChanged._id);
await db.action(async() => { await db.action(async() => {
@ -333,7 +333,7 @@ const RocketChat = {
// set Server // set Server
const currentServer = { server }; const currentServer = { server };
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
try { try {
const serverRecord = await serversCollection.find(server); const serverRecord = await serversCollection.find(server);
currentServer.version = serverRecord.version; currentServer.version = serverRecord.version;
@ -348,7 +348,7 @@ const RocketChat = {
// set Settings // set Settings
const settings = ['Accounts_AvatarBlockUnauthenticatedAccess']; const settings = ['Accounts_AvatarBlockUnauthenticatedAccess'];
const db = database.active; const db = database.active;
const settingsCollection = db.collections.get('settings'); const settingsCollection = db.get('settings');
const settingsRecords = await settingsCollection.query(Q.where('id', Q.oneOf(settings))).fetch(); const settingsRecords = await settingsCollection.query(Q.where('id', Q.oneOf(settings))).fetch();
const parsed = Object.values(settingsRecords).map(item => ({ const parsed = Object.values(settingsRecords).map(item => ({
_id: item.id, _id: item.id,
@ -362,7 +362,7 @@ const RocketChat = {
// set User info // set User info
const userId = await UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`); const userId = await UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
const userCollections = serversDB.collections.get('users'); const userCollections = serversDB.get('users');
let user = null; let user = null;
if (userId) { if (userId) {
const userRecord = await userCollections.find(userId); const userRecord = await userCollections.find(userId);
@ -544,7 +544,7 @@ const RocketChat = {
try { try {
const serversDB = database.servers; const serversDB = database.servers;
await serversDB.action(async() => { await serversDB.action(async() => {
const serverCollection = serversDB.collections.get('servers'); const serverCollection = serversDB.get('servers');
const serverRecord = await serverCollection.find(server); const serverRecord = await serverCollection.find(server);
await serverRecord.update((s) => { await serverRecord.update((s) => {
s.roomsUpdatedAt = null; s.roomsUpdatedAt = null;
@ -604,7 +604,7 @@ const RocketChat = {
} }
const db = database.active; const db = database.active;
const likeString = sanitizeLikeString(searchText); const likeString = sanitizeLikeString(searchText);
let data = await db.collections.get('subscriptions').query( let data = await db.get('subscriptions').query(
Q.or( Q.or(
Q.where('name', Q.like(`%${ likeString }%`)), Q.where('name', Q.like(`%${ likeString }%`)),
Q.where('fname', Q.like(`%${ likeString }%`)) Q.where('fname', Q.like(`%${ likeString }%`))
@ -792,7 +792,7 @@ const RocketChat = {
async getRoom(rid) { async getRoom(rid) {
try { try {
const db = database.active; const db = database.active;
const room = await db.collections.get('subscriptions').find(rid); const room = await db.get('subscriptions').find(rid);
return Promise.resolve(room); return Promise.resolve(room);
} catch (error) { } catch (error) {
return Promise.reject(new Error('Room not found')); return Promise.reject(new Error('Room not found'));
@ -1174,7 +1174,7 @@ const RocketChat = {
*/ */
async hasPermission(permissions, rid) { async hasPermission(permissions, rid) {
const db = database.active; const db = database.active;
const subsCollection = db.collections.get('subscriptions'); const subsCollection = db.get('subscriptions');
let roomRoles = []; let roomRoles = [];
try { try {
// get the room from database // get the room from database

View File

@ -53,7 +53,7 @@ const handleRequest = function* handleRequest({ data }) {
try { try {
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
yield db.action(async() => { yield db.action(async() => {
await subCollection.create((s) => { await subCollection.create((s) => {
s._raw = sanitizedRaw({ id: sub.rid }, subCollection.schema); s._raw = sanitizedRaw({ id: sub.rid }, subCollection.schema);

View File

@ -27,7 +27,7 @@ const handleRequest = function* handleRequest({ data }) {
try { try {
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
yield db.action(async() => { yield db.action(async() => {
await subCollection.create((s) => { await subCollection.create((s) => {
s._raw = sanitizedRaw({ id: sub.rid }, subCollection.schema); s._raw = sanitizedRaw({ id: sub.rid }, subCollection.schema);

View File

@ -72,7 +72,7 @@ const fallbackNavigation = function* fallbackNavigation() {
const handleOpen = function* handleOpen({ params }) { const handleOpen = function* handleOpen({ params }) {
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
let { host } = params; let { host } = params;
if (params.isCall && !host) { if (params.isCall && !host) {

View File

@ -30,7 +30,7 @@ const handleEncryptionInit = function* handleEncryptionInit() {
// Fetch server info to check E2E enable // Fetch server info to check E2E enable
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
let serverInfo; let serverInfo;
try { try {
serverInfo = yield serversCollection.find(server); serverInfo = yield serversCollection.find(server);

View File

@ -38,7 +38,7 @@ const restore = function* restore() {
yield put(appStart({ root: ROOT_OUTSIDE })); yield put(appStart({ root: ROOT_OUTSIDE }));
} else { } else {
const serversDB = database.servers; const serversDB = database.servers;
const serverCollections = serversDB.collections.get('servers'); const serverCollections = serversDB.get('servers');
let serverObj; let serverObj;
try { try {

View File

@ -57,7 +57,7 @@ const handleLoginRequest = function* handleLoginRequest({ credentials, logoutOnE
// Saves username on server history // Saves username on server history
const serversDB = database.servers; const serversDB = database.servers;
const serversHistoryCollection = serversDB.collections.get('servers_history'); const serversHistoryCollection = serversDB.get('servers_history');
yield serversDB.action(async() => { yield serversDB.action(async() => {
try { try {
const serversHistory = await serversHistoryCollection.query(Q.where('url', server)).fetch(); const serversHistory = await serversHistoryCollection.query(Q.where('url', server)).fetch();
@ -145,7 +145,7 @@ const handleLoginSuccess = function* handleLoginSuccess({ user }) {
moment.locale(toMomentLocale(user.language)); moment.locale(toMomentLocale(user.language));
const serversDB = database.servers; const serversDB = database.servers;
const usersCollection = serversDB.collections.get('users'); const usersCollection = serversDB.get('users');
const u = { const u = {
token: user.token, token: user.token,
username: user.username, username: user.username,
@ -222,7 +222,7 @@ const handleLogout = function* handleLogout({ forcedByServer }) {
} else { } else {
const serversDB = database.servers; const serversDB = database.servers;
// all servers // all servers
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
const servers = yield serversCollection.query().fetch(); const servers = yield serversCollection.query().fetch();
// see if there're other logged in servers and selects first one // see if there're other logged in servers and selects first one

View File

@ -12,7 +12,7 @@ const handleReplyBroadcast = function* handleReplyBroadcast({ message }) {
try { try {
const db = database.active; const db = database.active;
const { username } = message.u; const { username } = message.u;
const subsCollection = db.collections.get('subscriptions'); const subsCollection = db.get('subscriptions');
const subscriptions = yield subsCollection.query(Q.where('name', username)).fetch(); const subscriptions = yield subsCollection.query(Q.where('name', username)).fetch();
const isMasterDetail = yield select(state => state.app.isMasterDetail); const isMasterDetail = yield select(state => state.app.isMasterDetail);

View File

@ -15,7 +15,7 @@ import protectedFunction from '../lib/methods/helpers/protectedFunction';
const updateRooms = function* updateRooms({ server, newRoomsUpdatedAt }) { const updateRooms = function* updateRooms({ server, newRoomsUpdatedAt }) {
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
try { try {
const serverRecord = yield serversCollection.find(server); const serverRecord = yield serversCollection.find(server);
@ -39,7 +39,7 @@ const handleRoomsRequest = function* handleRoomsRequest({ params }) {
if (params.allData) { if (params.allData) {
yield put(roomsRefresh()); yield put(roomsRefresh());
} else { } else {
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
try { try {
const serverRecord = yield serversCollection.find(server); const serverRecord = yield serversCollection.find(server);
({ roomsUpdatedAt } = serverRecord); ({ roomsUpdatedAt } = serverRecord);
@ -51,8 +51,8 @@ const handleRoomsRequest = function* handleRoomsRequest({ params }) {
const { subscriptions } = yield mergeSubscriptionsRooms(subscriptionsResult, roomsResult); const { subscriptions } = yield mergeSubscriptionsRooms(subscriptionsResult, roomsResult);
const db = database.active; const db = database.active;
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
const messagesCollection = db.collections.get('messages'); const messagesCollection = db.get('messages');
const subsIds = subscriptions.map(sub => sub.rid).concat(roomsResult.remove.map(room => room._id)); const subsIds = subscriptions.map(sub => sub.rid).concat(roomsResult.remove.map(room => room._id));
if (subsIds.length) { if (subsIds.length) {

View File

@ -46,7 +46,7 @@ const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
} }
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
yield serversDB.action(async() => { yield serversDB.action(async() => {
try { try {
const serverRecord = await serversCollection.find(server); const serverRecord = await serversCollection.find(server);
@ -78,7 +78,7 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
const serversDB = database.servers; const serversDB = database.servers;
yield UserPreferences.setStringAsync(RocketChat.CURRENT_SERVER, server); yield UserPreferences.setStringAsync(RocketChat.CURRENT_SERVER, server);
const userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`); const userId = yield UserPreferences.getStringAsync(`${ RocketChat.TOKEN_KEY }-${ server }`);
const userCollections = serversDB.collections.get('users'); const userCollections = serversDB.get('users');
let user = null; let user = null;
if (userId) { if (userId) {
try { try {
@ -152,7 +152,7 @@ const handleServerRequest = function* handleServerRequest({ server, username, fr
const serverInfo = yield getServerInfo({ server }); const serverInfo = yield getServerInfo({ server });
const serversDB = database.servers; const serversDB = database.servers;
const serversHistoryCollection = serversDB.collections.get('servers_history'); const serversHistoryCollection = serversDB.get('servers_history');
if (serverInfo) { if (serverInfo) {
yield RocketChat.getLoginServices(server); yield RocketChat.getLoginServices(server);

View File

@ -17,7 +17,7 @@ import { setLocalAuthenticated } from '../actions/login';
export const saveLastLocalAuthenticationSession = async(server, serverRecord) => { export const saveLastLocalAuthenticationSession = async(server, serverRecord) => {
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
await serversDB.action(async() => { await serversDB.action(async() => {
try { try {
if (!serverRecord) { if (!serverRecord) {
@ -91,7 +91,7 @@ export const checkHasPasscode = async({ force = true, serverRecord }) => {
export const localAuthenticate = async(server) => { export const localAuthenticate = async(server) => {
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
let serverRecord; let serverRecord;
try { try {

View File

@ -22,7 +22,7 @@ const SelectUsers = ({
const getUsers = debounce(async(keyword = '') => { const getUsers = debounce(async(keyword = '') => {
try { try {
const db = database.active; const db = database.active;
const usersCollection = db.collections.get('users'); const usersCollection = db.get('users');
const res = await RocketChat.search({ text: keyword, filterRooms: false }); const res = await RocketChat.search({ text: keyword, filterRooms: false });
let items = [...users.filter(u => selected.includes(u.name)), ...res.filter(r => !users.find(u => u.name === r.name))]; let items = [...users.filter(u => selected.includes(u.name)), ...res.filter(r => !users.find(u => u.name === r.name))];
const records = await usersCollection.query(Q.where('username', Q.oneOf(items.map(u => u.name)))).fetch(); const records = await usersCollection.query(Q.where('username', Q.oneOf(items.map(u => u.name)))).fetch();

View File

@ -94,7 +94,7 @@ class LanguageView extends React.Component {
setUser({ language: params.language }); setUser({ language: params.language });
const serversDB = database.servers; const serversDB = database.servers;
const usersCollection = serversDB.collections.get('users'); const usersCollection = serversDB.get('users');
await serversDB.action(async() => { await serversDB.action(async() => {
try { try {
const userRecord = await usersCollection.find(user.id); const userRecord = await usersCollection.find(user.id);

View File

@ -132,7 +132,7 @@ class NewServerView extends React.Component {
queryServerHistory = async(text) => { queryServerHistory = async(text) => {
const db = database.servers; const db = database.servers;
try { try {
const serversHistoryCollection = db.collections.get('servers_history'); const serversHistoryCollection = db.get('servers_history');
let whereClause = [ let whereClause = [
Q.where('username', Q.notEq(null)), Q.where('username', Q.notEq(null)),
Q.experimentalSortBy('updated_at', Q.desc), Q.experimentalSortBy('updated_at', Q.desc),

View File

@ -109,7 +109,7 @@ class RoomInfoEditView extends React.Component {
} }
try { try {
const db = database.active; const db = database.active;
const sub = await db.collections.get('subscriptions').find(rid); const sub = await db.get('subscriptions').find(rid);
const observable = sub.observe(); const observable = sub.observe();
this.querySubscription = observable.subscribe((data) => { this.querySubscription = observable.subscribe((data) => {

View File

@ -136,7 +136,7 @@ class RoomInfoView extends React.Component {
getRoleDescription = async(id) => { getRoleDescription = async(id) => {
const db = database.active; const db = database.active;
try { try {
const rolesCollection = db.collections.get('roles'); const rolesCollection = db.get('roles');
const role = await rolesCollection.find(id); const role = await rolesCollection.find(id);
if (role) { if (role) {
return role.description; return role.description;

View File

@ -146,7 +146,7 @@ class RoomMembersView extends React.Component {
navToDirectMessage = async(item) => { navToDirectMessage = async(item) => {
try { try {
const db = database.active; const db = database.active;
const subsCollection = db.collections.get('subscriptions'); const subsCollection = db.get('subscriptions');
const query = await subsCollection.query(Q.where('name', item.username)).fetch(); const query = await subsCollection.query(Q.where('name', item.username)).fetch();
if (query.length) { if (query.length) {
const [room] = query; const [room] = query;

View File

@ -35,7 +35,7 @@ class RightButtonsContainer extends Component {
const db = database.active; const db = database.active;
if (tmid) { if (tmid) {
try { try {
const threadRecord = await db.collections.get('messages').find(tmid); const threadRecord = await db.get('messages').find(tmid);
this.observeThread(threadRecord); this.observeThread(threadRecord);
} catch (e) { } catch (e) {
console.log('Can\'t find message to observe.'); console.log('Can\'t find message to observe.');
@ -43,7 +43,7 @@ class RightButtonsContainer extends Component {
} }
if (rid) { if (rid) {
try { try {
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
const subRecord = await subCollection.find(rid); const subRecord = await subCollection.find(rid);
this.observeSubscription(subRecord); this.observeSubscription(subRecord);
} catch (e) { } catch (e) {

View File

@ -251,7 +251,7 @@ class RoomView extends React.Component {
let obj; let obj;
if (this.tmid) { if (this.tmid) {
try { try {
const threadsCollection = db.collections.get('threads'); const threadsCollection = db.get('threads');
obj = await threadsCollection.find(this.tmid); obj = await threadsCollection.find(this.tmid);
} catch (e) { } catch (e) {
// Do nothing // Do nothing
@ -400,7 +400,7 @@ class RoomView extends React.Component {
const db = database.active; const db = database.active;
try { try {
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
const sub = await subCollection.find(this.rid); const sub = await subCollection.find(this.rid);
const { room } = await RocketChat.getRoomInfo(this.rid); const { room } = await RocketChat.getRoomInfo(this.rid);
@ -475,7 +475,7 @@ class RoomView extends React.Component {
findAndObserveRoom = async(rid) => { findAndObserveRoom = async(rid) => {
try { try {
const db = database.active; const db = database.active;
const subCollection = await db.collections.get('subscriptions'); const subCollection = await db.get('subscriptions');
const room = await subCollection.find(rid); const room = await subCollection.find(rid);
this.setState({ room }); this.setState({ room });
if (!this.tmid) { if (!this.tmid) {
@ -750,8 +750,8 @@ class RoomView extends React.Component {
fetchThreadName = async(tmid, messageId) => { fetchThreadName = async(tmid, messageId) => {
try { try {
const db = database.active; const db = database.active;
const threadCollection = db.collections.get('threads'); const threadCollection = db.get('threads');
const messageCollection = db.collections.get('messages'); const messageCollection = db.get('messages');
const messageRecord = await messageCollection.find(messageId); const messageRecord = await messageCollection.find(messageId);
let threadRecord; let threadRecord;
try { try {

View File

@ -620,7 +620,7 @@ class RoomsListView extends React.Component {
const db = database.active; const db = database.active;
const result = await RocketChat.toggleFavorite(rid, !favorite); const result = await RocketChat.toggleFavorite(rid, !favorite);
if (result.success) { if (result.success) {
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
await db.action(async() => { await db.action(async() => {
try { try {
const subRecord = await subCollection.find(rid); const subRecord = await subCollection.find(rid);
@ -644,7 +644,7 @@ class RoomsListView extends React.Component {
const db = database.active; const db = database.active;
const result = await RocketChat.toggleRead(isRead, rid); const result = await RocketChat.toggleRead(isRead, rid);
if (result.success) { if (result.success) {
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
await db.action(async() => { await db.action(async() => {
try { try {
const subRecord = await subCollection.find(rid); const subRecord = await subCollection.find(rid);
@ -668,7 +668,7 @@ class RoomsListView extends React.Component {
const db = database.active; const db = database.active;
const result = await RocketChat.hideRoom(rid, type); const result = await RocketChat.hideRoom(rid, type);
if (result.success) { if (result.success) {
const subCollection = db.collections.get('subscriptions'); const subCollection = db.get('subscriptions');
await db.action(async() => { await db.action(async() => {
try { try {
const subRecord = await subCollection.find(rid); const subRecord = await subCollection.find(rid);

View File

@ -71,7 +71,7 @@ class ScreenLockConfigView extends React.Component {
init = async() => { init = async() => {
const { server } = this.props; const { server } = this.props;
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
try { try {
this.serverRecord = await serversCollection.find(server); this.serverRecord = await serversCollection.find(server);
this.setState({ this.setState({

View File

@ -84,7 +84,7 @@ class SearchMessagesView extends React.Component {
// If it's a encrypted, room we'll search only on the local stored messages // If it's a encrypted, room we'll search only on the local stored messages
if (this.encrypted) { if (this.encrypted) {
const db = database.active; const db = database.active;
const messagesCollection = db.collections.get('messages'); const messagesCollection = db.get('messages');
const likeString = sanitizeLikeString(searchText); const likeString = sanitizeLikeString(searchText);
return messagesCollection return messagesCollection
.query( .query(

View File

@ -29,7 +29,7 @@ class SelectServerView extends React.Component {
async componentDidMount() { async componentDidMount() {
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
const servers = await serversCollection.query(Q.where('rooms_updated_at', Q.notEq(null))).fetch(); const servers = await serversCollection.query(Q.where('rooms_updated_at', Q.notEq(null))).fetch();
this.setState({ servers }); this.setState({ servers });
} }

View File

@ -62,7 +62,7 @@ class SettingsView extends React.Component {
checkCookiesAndLogout = async() => { checkCookiesAndLogout = async() => {
const { logout, user } = this.props; const { logout, user } = this.props;
const db = database.servers; const db = database.servers;
const usersCollection = db.collections.get('users'); const usersCollection = db.get('users');
try { try {
const userRecord = await usersCollection.find(user.id); const userRecord = await usersCollection.find(user.id);
if (!userRecord.loginEmailPassword) { if (!userRecord.loginEmailPassword) {

View File

@ -206,7 +206,7 @@ class ShareListView extends React.Component {
) )
); );
} }
const data = await db.collections.get('subscriptions').query(...defaultWhereClause).fetch(); const data = await db.get('subscriptions').query(...defaultWhereClause).fetch();
return data.map(item => ({ return data.map(item => ({
rid: item.rid, rid: item.rid,
t: item.t, t: item.t,
@ -226,7 +226,7 @@ class ShareListView extends React.Component {
if (server) { if (server) {
const chats = await this.query(); const chats = await this.query();
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
const serversCount = await serversCollection.query(Q.where('rooms_updated_at', Q.notEq(null))).fetchCount(); const serversCount = await serversCollection.query(Q.where('rooms_updated_at', Q.notEq(null))).fetchCount();
let serverInfo = {}; let serverInfo = {};
try { try {

View File

@ -95,7 +95,7 @@ class ShareView extends Component {
getServerInfo = async() => { getServerInfo = async() => {
const { server } = this.props; const { server } = this.props;
const serversDB = database.servers; const serversDB = database.servers;
const serversCollection = serversDB.collections.get('servers'); const serversCollection = serversDB.get('servers');
try { try {
this.serverInfo = await serversCollection.find(server); this.serverInfo = await serversCollection.find(server);
} catch (error) { } catch (error) {

View File

@ -241,7 +241,7 @@ class ThreadMessagesView extends React.Component {
try { try {
const db = database.active; const db = database.active;
const threadsCollection = db.collections.get('threads'); const threadsCollection = db.get('threads');
const allThreadsRecords = await subscription.threads.fetch(); const allThreadsRecords = await subscription.threads.fetch();
let threadsToCreate = []; let threadsToCreate = [];
let threadsToUpdate = []; let threadsToUpdate = [];