Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
toLogin() {
let {login} = this.props;
if (!this.params.userName || this.params.userName.length === 0) {
Toast(I18n('LoginNameTip'));
return
}
if (!this.params.password || this.params.password.length === 0) {
Toast(I18n('LoginPWTip'));
return
}
this.setState({
saveUserName: this.params.userName,
savePassword: this.params.password
});
Actions.LoadingModal({backExit: false});
Keyboard.dismiss();
login.doLogin(this.params.userName, this.params.password, (res) => {
this.exitLoading();
if (!res) {
Toast(I18n('LoginFailTip'));
} else {
Actions.reset("root")
}
})
}
doFollowLogic() {
Actions.LoadingModal({backExit: false});
userAction.doFollow(this.props.currentUser, !this.state.hadFollowed).then(() => {
this._refreshInfo();
setTimeout(() => {
Actions.pop();
}, 500);
})
}
}
editComment(commentId, text, rowID) {
let {repositoryName, userName} = this.props;
let {issue} = this.state;
Actions.LoadingModal({backExit: false});
issueActions.editComment(userName, repositoryName, issue.number, commentId,
{body: text}).then((res) => {
setTimeout(() => {
Actions.pop();
if (res && res.result) {
let dataList = this.state.dataSource;
dataList.splice(parseInt(rowID), 1, res.data);
this.setState({
dataSource: dataList
})
} else {
Actions.TextInputModal({
textConfirm: (text) => {
this.editComment(commentId, text, rowID)
},
titleText: I18n('editIssue'),
sendIssueComment(text) {
let {repositoryName, userName} = this.props;
let {issue} = this.state;
Actions.LoadingModal({backExit: false});
issueActions.addIssueComment(userName, repositoryName, issue.number, text).then((res) => {
setTimeout(() => {
Actions.pop();
if (res && res.result) {
let dataList = this.state.dataSource;
dataList.push(res.data);
this.setState({
dataSource: dataList
})
} else {
Actions.TextInputModal({
needEditTitle: false,
textConfirm: this.sendIssueComment,
text: text,
titleText: I18n('commentsIssue'),
bottomBar: true,
lockedIssue() {
let {repositoryName, userName} = this.props;
let {issue} = this.state;
Actions.LoadingModal({backExit: false});
issueActions.lockIssue(userName, repositoryName, issue.number, issue.locked).then((res) => {
setTimeout(() => {
Actions.pop();
if (res && res.result && res.data) {
this.setState({
issue: res.data
})
}
}, 500);
})
}
_createIssue(text, title) {
let {repositoryName, userName} = this.props;
Actions.LoadingModal({backExit: false});
issueActions.createIssue(userName, repositoryName,
{title: title, body: text}).then((res) => {
setTimeout(() => {
Actions.pop();
if (res && res.data) {
let data = this.state.dataSource;
data.splice(0, 0, res.data);
this.setState({
dataSource: data,
})
}
}, 500);
})
}
postChanged(params) {
Actions.LoadingModal({backExit: false});
userActions.updateUser(params).then(() => {
setTimeout((res) => {
Actions.pop();
}, 500);
});
}
editIssue(text, title) {
if (!title || title.length === 0) {
return
}
let {repositoryName, userName} = this.props;
let {issue} = this.state;
Actions.LoadingModal({backExit: false});
issueActions.editIssue(userName, repositoryName, issue.number,
{title: title, body: text}).then((res) => {
setTimeout(() => {
Actions.pop();
if (res && res.result) {
this.setState({
issue: res.data
})
} else {
Actions.TextInputModal({
textConfirm: this.editIssue,
titleText: I18n('editIssue'),
needEditTitle: true,
text: text,
titleValue: title,
bottomBar: true,
rightBtnPress: () => {
Actions.LoadingModal({backExit: false});
userActions.setAllNotificationAsRead().then((res) => {
Actions.pop();
setTimeout(() => {
if (res && res.result) {
Actions.pop();
}
}, 500);
})
}
});
itemClick: () => {
Actions.LoadingModal({backExit: false});
repositoryActions.doRepositoryWatch(ownerName, repositoryName, !watched).then((res) => {
setTimeout(() => {
Actions.pop();
this._refresh();
}, 500);
})
}, itemStyle: {
borderLeftWidth: StyleSheet.hairlineWidth, borderLeftColor: Constant.lineColor,