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