Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lista mensajerias #1579

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
var refreshToken = function(baseURL, refreshToken) {

return axios({
method: 'POST',

Check warning on line 569 in src/API.js

View workflow job for this annotation

GitHub Actions / Basic tests

'refreshToken' is already declared in the upper scope on line 569 column 5
url: `${baseURL}/api/token/refresh`,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
Expand Down Expand Up @@ -695,14 +695,14 @@
}
}

const checkServer = function(server) {
const checkServer = function(server, quick) {
return new Promise((resolve, reject) => {
resolveBaseURL(server)
.then((baseURL) => {

console.log('Base URL is ' + baseURL)

if (quick == true) {
resolve(baseURL);
}
axios

Check warning on line 705 in src/API.js

View workflow job for this annotation

GitHub Actions / Basic tests

Expected '===' and instead saw '=='
.get(`${baseURL}/api`, {
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -731,6 +731,7 @@
.catch(error => {
if (error.response) {
if (error.response.status === 503) {
console.log(baseURL + ' is under maintenace');
reject(createError(ERROR_MAINTENANCE_ON))
} else {
reject(createError(ERROR_NOT_COMPATIBLE))
Expand Down
23 changes: 19 additions & 4 deletions src/Server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
import axios from 'axios'
import API from './API'

const load = () => {

Expand All @@ -8,10 +9,8 @@
AsyncStorage.getItem('@CoopCycle.servers')
.then((data, e) => {
if (e || !data) {

return resolve([])
}

resolve(JSON.parse(data))
})
} catch (e) {
Expand Down Expand Up @@ -47,9 +46,25 @@
})
}

function overrideCity(values) {

async function overrideCity(values) {
const fail = Symbol()

Check warning on line 51 in src/Server.js

View workflow job for this annotation

GitHub Actions / Basic tests

'fail' is assigned a value but never used

const promises = values.map(async(n) => ({
value: n,
include: await API.checkServer(n.url, true).then(value => {
return true;
}).catch(err => {
console.log(err); // 👉️ "Something went wrong"
return false;
})

Check warning on line 60 in src/Server.js

View workflow job for this annotation

GitHub Actions / Basic tests

Missing trailing comma
}));
const data_with_includes = await Promise.all(promises);
const filtered_data_with_includes = data_with_includes.filter(v => v.include);
const filtered_data = filtered_data_with_includes.map(data => data.value);
values = filtered_data;
return values.map((value) => {

if (value.city.startsWith('Ciudad de México')) {
return {
...value,
Expand Down Expand Up @@ -86,4 +101,4 @@

}

export default Server
export default Server

Check warning on line 104 in src/Server.js

View workflow job for this annotation

GitHub Actions / Basic tests

Newline required at end of file but not found
4 changes: 2 additions & 2 deletions src/redux/App/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,13 @@ function loadAll(getState) {
}

export function selectServer(server) {

console.log('selected server: ' + server);
return function (dispatch, getState) {

dispatch(setLoading(true))
dispatch(_clearSelectServerError())

return API.checkServer(server)
return API.checkServer(server, false)
.then(baseURL =>
Settings.synchronize(baseURL)
.then((settings) => {
Expand Down
Loading