[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 { Q } from '@nozbe/watermelondb';
|
||||
|
||||
import RocketChat from '../rocketchat';
|
||||
import reduxStore from '../createStore';
|
||||
import * as actions from '../../actions';
|
||||
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() {
|
||||
try {
|
||||
const db = database.active;
|
||||
|
|
|
@ -27,7 +27,7 @@ import subscribeRoom from './methods/subscriptions/room';
|
|||
|
||||
import protectedFunction from './methods/helpers/protectedFunction';
|
||||
import readMessages from './methods/readMessages';
|
||||
import getSettings from './methods/getSettings';
|
||||
import getSettings, { setSettings } from './methods/getSettings';
|
||||
|
||||
import getRooms from './methods/getRooms';
|
||||
import getPermissions from './methods/getPermissions';
|
||||
|
@ -532,6 +532,7 @@ const RocketChat = {
|
|||
cancelUpload,
|
||||
isUploadActive,
|
||||
getSettings,
|
||||
setSettings,
|
||||
getPermissions,
|
||||
getCustomEmojis,
|
||||
setCustomEmojis,
|
||||
|
|
|
@ -90,19 +90,10 @@ const handleSelectServer = function* handleSelectServer({ server, version, fetch
|
|||
yield put(actions.appStart('outside'));
|
||||
}
|
||||
|
||||
const db = database.active;
|
||||
const serversCollection = db.collections.get('settings');
|
||||
const settingsRecords = yield serversCollection.query().fetch();
|
||||
const settings = Object.values(settingsRecords).map(item => ({
|
||||
_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();
|
||||
// We can't use yield here because fetch of Settings & Custom Emojis is slower
|
||||
// and block the selectServerSuccess raising multiples errors
|
||||
RocketChat.setSettings();
|
||||
RocketChat.setCustomEmojis();
|
||||
|
||||
let serverInfo;
|
||||
if (fetchVersion) {
|
||||
|
|
Loading…
Reference in New Issue