Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
RocketChat
Rocket.Chat.ReactNative
Commits
62db1ec9
Commit
62db1ec9
authored
Jan 07, 2020
by
Djorkaeff Alexandre
Committed by
Diego Mello
Jan 07, 2020
Browse files
[CHORE] Update to new server response (#1509)
parent
1aadb883
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/sagas/selectServer.js
View file @
62db1ec9
...
...
@@ -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
.
v
ersion
;
record
.
version
=
validV
ersion
;
});
}
catch
(
e
)
{
await
serversCollection
.
create
((
record
)
=>
{
record
.
_raw
=
sanitizedRaw
({
id
:
server
},
serversCollection
.
schema
);
record
.
version
=
serverInfo
.
v
ersion
;
record
.
version
=
validV
ersion
;
});
}
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment