Merged branch master into master
This commit is contained in:
commit
388e648b26
4 changed files with 16 additions and 12 deletions
|
@ -1,7 +1,9 @@
|
||||||
const TOKEN = '';
|
import token from './token';
|
||||||
|
|
||||||
export default function request(url, method, data = {}, token = TOKEN ) {
|
export default function request(url, method, data = {}, CIToken) {
|
||||||
const fullURL = url.query({ 'circle-token': token }).toString();
|
CIToken = CIToken || token.get();
|
||||||
|
const fullURL = url.query({ 'circle-token': CIToken }).toString();
|
||||||
|
console.log('Sending request to', fullURL);
|
||||||
let fetchParams = {
|
let fetchParams = {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
|
|
|
@ -2,10 +2,12 @@ import { AsyncStorage } from 'react-native';
|
||||||
|
|
||||||
const STORAGE_KEY = 'CIRCLE_TOKEN';
|
const STORAGE_KEY = 'CIRCLE_TOKEN';
|
||||||
|
|
||||||
export async function get() {
|
async function get() {
|
||||||
return await AsyncStorage.getItem(STORAGE_KEY);
|
return await AsyncStorage.getItem(STORAGE_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function set(token) {
|
async function set(token) {
|
||||||
return await AsyncStorage.setItem(STORAGE_KEY, token);
|
return await AsyncStorage.setItem(STORAGE_KEY, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default { get, set };
|
||||||
|
|
|
@ -45,7 +45,7 @@ export default class Home extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const data = JSON.stringify(this.state.projects);
|
const data = JSON.stringify(this.state.projects) || 'No Data';
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<ScrollView keyboardShouldPersistTaps={false} contentContainerStyle={styles.container}>
|
<ScrollView keyboardShouldPersistTaps={false} contentContainerStyle={styles.container}>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import GlobalStyles from '../../settings/styles';
|
||||||
import TokenHelp from '../login/token-help';
|
import TokenHelp from '../login/token-help';
|
||||||
import RouteMaster from './RouteMaster';
|
import RouteMaster from './RouteMaster';
|
||||||
import { checkToken } from '../../api/CircleCI';
|
import { checkToken } from '../../api/CircleCI';
|
||||||
import { set } from '../../api/token';
|
import token from '../../api/token';
|
||||||
import loaderHandler from 'react-native-busy-indicator/LoaderHandler';
|
import loaderHandler from 'react-native-busy-indicator/LoaderHandler';
|
||||||
import BusyIndicator from 'react-native-busy-indicator';
|
import BusyIndicator from 'react-native-busy-indicator';
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
input: {
|
input: {
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
marginHorizontal: 15,
|
marginHorizontal: 25,
|
||||||
},
|
},
|
||||||
loginButton: {
|
loginButton: {
|
||||||
flex: 0.92,
|
flex: 0.92,
|
||||||
|
@ -81,7 +81,7 @@ export default class Login extends React.Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = {
|
this.state = {
|
||||||
token: '',
|
token: '07e1082a9298c939b4f1c2c5821225012d8fd34e',
|
||||||
showTokenHelp: false
|
showTokenHelp: false
|
||||||
};
|
};
|
||||||
this.animate = new Animated.Value(2);
|
this.animate = new Animated.Value(2);
|
||||||
|
@ -105,8 +105,8 @@ export default class Login extends React.Component {
|
||||||
this.proceed = this.proceed.bind(this);
|
this.proceed = this.proceed.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
textChanged(token) {
|
textChanged(CIToken) {
|
||||||
this.setState({ token });
|
this.setState({ token: CIToken });
|
||||||
}
|
}
|
||||||
|
|
||||||
proceed() {
|
proceed() {
|
||||||
|
@ -130,7 +130,7 @@ export default class Login extends React.Component {
|
||||||
}
|
}
|
||||||
checkToken(this.state.token).then(function (isValid) {
|
checkToken(this.state.token).then(function (isValid) {
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
set(this.state.token).then(this.proceed);
|
token.set(this.state.token).then(this.proceed);
|
||||||
} else {
|
} else {
|
||||||
this.invalidToken();
|
this.invalidToken();
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
Reference in a new issue