From 07f9933469c4c91c7b50d4e1e27778654fa3a8b8 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 31 Dec 2019 15:34:40 -0300 Subject: [PATCH] [CHORE] Update to new server response --- app/sagas/selectServer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/sagas/selectServer.js b/app/sagas/selectServer.js index 0294edc001..0fd9938fe1 100644 --- a/app/sagas/selectServer.js +++ b/app/sagas/selectServer.js @@ -4,6 +4,7 @@ import { import { Alert } from 'react-native'; import RNUserDefaults from 'rn-user-defaults'; import { sanitizedRaw } from '@nozbe/watermelondb/RawRecord'; +import semver from 'semver'; import Navigation from '../lib/Navigation'; import { SERVER } from '../actions/actionsTypes'; @@ -35,18 +36,20 @@ const getServerInfo = function* getServerInfo({ server, raiseError = true }) { return; } + const validVersion = semver.coerce(serverInfo.version); + const serversDB = database.servers; const serversCollection = serversDB.collections.get('servers'); yield serversDB.action(async() => { try { const serverRecord = await serversCollection.find(server); await serverRecord.update((record) => { - record.version = serverInfo.version; + record.version = validVersion; }); } catch (e) { await serversCollection.create((record) => { record._raw = sanitizedRaw({ id: server }, serversCollection.schema); - record.version = serverInfo.version; + record.version = validVersion; }); } });