[FIX] Invalid server version (#1319)
This commit is contained in:
parent
d52a7e00cc
commit
8bffe1f28c
|
@ -2,6 +2,7 @@ import { InteractionManager } from 'react-native';
|
||||||
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
|
import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord';
|
||||||
import { Q } from '@nozbe/watermelondb';
|
import { Q } from '@nozbe/watermelondb';
|
||||||
|
|
||||||
|
import RocketChat from '../rocketchat';
|
||||||
import reduxStore from '../createStore';
|
import reduxStore from '../createStore';
|
||||||
import * as actions from '../../actions';
|
import * as actions from '../../actions';
|
||||||
import settings from '../../constants/settings';
|
import settings from '../../constants/settings';
|
||||||
|
@ -51,6 +52,20 @@ const serverInfoUpdate = async(serverInfo, iconSetting) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export async function setSettings() {
|
||||||
|
const db = database.active;
|
||||||
|
const settingsCollection = db.collections.get('settings');
|
||||||
|
const settingsRecords = await settingsCollection.query().fetch();
|
||||||
|
const parsed = Object.values(settingsRecords).map(item => ({
|
||||||
|
_id: item.id,
|
||||||
|
valueAsString: item.valueAsString,
|
||||||
|
valueAsBoolean: item.valueAsBoolean,
|
||||||
|
valueAsNumber: item.valueAsNumber,
|
||||||
|
_updatedAt: item._updatedAt
|
||||||
|
}));
|
||||||
|
reduxStore.dispatch(actions.setAllSettings(RocketChat.parseSettings(parsed.slice(0, parsed.length))));
|
||||||
|
}
|
||||||
|
|
||||||
export default async function() {
|
export default async function() {
|
||||||
try {
|
try {
|
||||||
const db = database.active;
|
const db = database.active;
|
||||||
|
|
|
@ -27,7 +27,7 @@ import subscribeRoom from './methods/subscriptions/room';
|
||||||
|
|
||||||
import protectedFunction from './methods/helpers/protectedFunction';
|
import protectedFunction from './methods/helpers/protectedFunction';
|
||||||
import readMessages from './methods/readMessages';
|
import readMessages from './methods/readMessages';
|
||||||
import getSettings from './methods/getSettings';
|
import getSettings, { setSettings } from './methods/getSettings';
|
||||||
|
|
||||||
import getRooms from './methods/getRooms';
|
import getRooms from './methods/getRooms';
|
||||||
import getPermissions from './methods/getPermissions';
|
import getPermissions from './methods/getPermissions';
|
||||||
|
@ -532,6 +532,7 @@ const RocketChat = {
|
||||||
cancelUpload,
|
cancelUpload,
|
||||||
isUploadActive,
|
isUploadActive,
|
||||||
getSettings,
|
getSettings,
|
||||||
|
setSettings,
|
||||||
getPermissions,
|
getPermissions,
|
||||||
getCustomEmojis,
|
getCustomEmojis,
|
||||||
setCustomEmojis,
|
setCustomEmojis,
|
||||||
|
|
|
@ -90,19 +90,10 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
|
||||||
yield put(actions.appStart('outside'));
|
yield put(actions.appStart('outside'));
|
||||||
}
|
}
|
||||||
|
|
||||||
const db = database.active;
|
// We can't use yield here because fetch of Settings & Custom Emojis is slower
|
||||||
const serversCollection = db.collections.get('settings');
|
// and block the selectServerSuccess raising multiples errors
|
||||||
const settingsRecords = yield serversCollection.query().fetch();
|
RocketChat.setSettings();
|
||||||
const settings = Object.values(settingsRecords).map(item => ({
|
RocketChat.setCustomEmojis();
|
||||||
_id: item.id,
|
|
||||||
valueAsString: item.valueAsString,
|
|
||||||
valueAsBoolean: item.valueAsBoolean,
|
|
||||||
valueAsNumber: item.valueAsNumber,
|
|
||||||
_updatedAt: item._updatedAt
|
|
||||||
}));
|
|
||||||
yield put(actions.setAllSettings(RocketChat.parseSettings(settings.slice(0, settings.length))));
|
|
||||||
|
|
||||||
yield RocketChat.setCustomEmojis();
|
|
||||||
|
|
||||||
let serverInfo;
|
let serverInfo;
|
||||||
if (fetchVersion) {
|
if (fetchVersion) {
|
||||||
|
|
Loading…
Reference in New Issue