use of com.fastaccess.data.dao.IssueRequestModel in project FastHub by k0shk0sh.
the class PullRequestPagerPresenter method onOpenCloseIssue.
@Override
public void onOpenCloseIssue() {
if (getPullRequest() != null) {
IssueRequestModel requestModel = IssueRequestModel.clone(getPullRequest(), true);
manageDisposable(RxHelper.getObservable(RestProvider.getPullRequestService(isEnterprise()).editPullRequest(login, repoId, issueNumber, requestModel)).doOnSubscribe(disposable -> sendToView(view -> view.showProgress(0))).subscribe(issue -> {
if (issue != null) {
sendToView(view -> view.showSuccessIssueActionMsg(getPullRequest().getState() == IssueState.open));
issue.setRepoId(getPullRequest().getRepoId());
issue.setLogin(getPullRequest().getLogin());
pullRequest = issue;
sendToView(view -> view.onSetupIssue(false));
}
}, throwable -> sendToView(view -> view.showErrorIssueActionMsg(getPullRequest().getState() == IssueState.open))));
}
}
use of com.fastaccess.data.dao.IssueRequestModel in project FastHub by k0shk0sh.
the class CreateIssuePresenter method onSubmit.
@Override
public void onSubmit(@NonNull String title, @NonNull CharSequence description, @NonNull String login, @NonNull String repo, @Nullable Issue issue, @Nullable PullRequest pullRequestModel, @Nullable ArrayList<LabelModel> labels, @Nullable MilestoneModel milestoneModel, @Nullable ArrayList<User> users) {
boolean isEmptyTitle = InputHelper.isEmpty(title);
if (getView() != null) {
getView().onTitleError(isEmptyTitle);
}
if (!isEmptyTitle) {
if (issue == null && pullRequestModel == null) {
CreateIssueModel createIssue = new CreateIssueModel();
createIssue.setBody(InputHelper.toString(description));
createIssue.setTitle(title);
if (isCollaborator) {
if (labels != null && !labels.isEmpty()) {
createIssue.setLabels(Stream.of(labels).map(LabelModel::getName).collect(Collectors.toCollection(ArrayList::new)));
}
if (users != null && !users.isEmpty()) {
createIssue.setAssignees(Stream.of(users).map(User::getLogin).collect(Collectors.toCollection(ArrayList::new)));
}
if (milestoneModel != null) {
createIssue.setMilestone((long) milestoneModel.getNumber());
}
}
makeRestCall(RestProvider.getIssueService(isEnterprise()).createIssue(login, repo, createIssue), issueModel -> {
if (issueModel != null) {
sendToView(view -> view.onSuccessSubmission(issueModel));
} else {
sendToView(view -> view.showMessage(R.string.error, R.string.error_creating_issue));
}
}, false);
} else {
if (issue != null) {
issue.setBody(InputHelper.toString(description));
issue.setTitle(title);
int number = issue.getNumber();
if (isCollaborator) {
if (labels != null) {
LabelListModel labelModels = new LabelListModel();
labelModels.addAll(labels);
issue.setLabels(labelModels);
}
if (milestoneModel != null) {
issue.setMilestone(milestoneModel);
}
if (users != null) {
UsersListModel usersListModel = new UsersListModel();
usersListModel.addAll(users);
issue.setAssignees(usersListModel);
}
}
IssueRequestModel requestModel = IssueRequestModel.clone(issue, false);
makeRestCall(RestProvider.getIssueService(isEnterprise()).editIssue(login, repo, number, requestModel), issueModel -> {
if (issueModel != null) {
sendToView(view -> view.onSuccessSubmission(issueModel));
} else {
sendToView(view -> view.showMessage(R.string.error, R.string.error_creating_issue));
}
}, false);
}
if (pullRequestModel != null) {
int number = pullRequestModel.getNumber();
pullRequestModel.setBody(InputHelper.toString(description));
pullRequestModel.setTitle(title);
if (isCollaborator) {
if (labels != null) {
LabelListModel labelModels = new LabelListModel();
labelModels.addAll(labels);
pullRequestModel.setLabels(labelModels);
}
if (milestoneModel != null) {
pullRequestModel.setMilestone(milestoneModel);
}
if (users != null) {
UsersListModel usersListModel = new UsersListModel();
usersListModel.addAll(users);
pullRequestModel.setAssignees(usersListModel);
}
}
IssueRequestModel requestModel = IssueRequestModel.clone(pullRequestModel, false);
makeRestCall(RestProvider.getPullRequestService(isEnterprise()).editPullRequest(login, repo, number, requestModel).flatMap(pullRequest1 -> RestProvider.getIssueService(isEnterprise()).getIssue(login, repo, number), (pullRequest1, issueReaction) -> {
// hack to get reactions from issue api
if (issueReaction != null) {
pullRequest1.setReactions(issueReaction.getReactions());
}
return pullRequest1;
}), pr -> {
if (pr != null) {
sendToView(view -> view.onSuccessSubmission(pr));
} else {
sendToView(view -> view.showMessage(R.string.error, R.string.error_creating_issue));
}
}, false);
}
}
}
}
use of com.fastaccess.data.dao.IssueRequestModel in project FastHub by k0shk0sh.
the class IssuePagerPresenter method onOpenCloseIssue.
@Override
public void onOpenCloseIssue() {
Issue currentIssue = getIssue();
if (currentIssue != null) {
IssueRequestModel requestModel = IssueRequestModel.clone(currentIssue, true);
manageDisposable(RxHelper.getObservable(RestProvider.getIssueService(isEnterprise()).editIssue(login, repoId, issueNumber, requestModel)).doOnSubscribe(disposable -> sendToView(view -> view.showProgress(0))).subscribe(issue -> {
if (issue != null) {
sendToView(view -> view.showSuccessIssueActionMsg(currentIssue.getState() == IssueState.open));
issue.setRepoId(issueModel.getRepoId());
issue.setLogin(issueModel.getLogin());
issueModel = issue;
sendToView(view -> view.onSetupIssue(false));
}
}, this::onError));
}
}
use of com.fastaccess.data.dao.IssueRequestModel in project FastHub by k0shk0sh.
the class IssuePagerPresenter method onPutMilestones.
@Override
public void onPutMilestones(@NonNull MilestoneModel milestone) {
issueModel.setMilestone(milestone);
IssueRequestModel issueRequestModel = IssueRequestModel.clone(issueModel, false);
makeRestCall(RestProvider.getIssueService(isEnterprise()).editIssue(login, repoId, issueNumber, issueRequestModel), issue -> {
this.issueModel.setMilestone(issue.getMilestone());
manageObservable(issue.save(issueModel).toObservable());
sendToView(view -> updateTimeline(view, R.string.labels_added_successfully));
});
}
use of com.fastaccess.data.dao.IssueRequestModel in project FastHub by k0shk0sh.
the class PullRequestPagerPresenter method onPutMilestones.
@Override
public void onPutMilestones(@NonNull MilestoneModel milestone) {
pullRequest.setMilestone(milestone);
IssueRequestModel issueRequestModel = IssueRequestModel.clone(pullRequest, false);
makeRestCall(RestProvider.getPullRequestService(isEnterprise()).editIssue(login, repoId, issueNumber, issueRequestModel), pr -> {
this.pullRequest.setMilestone(pr.getMilestone());
manageObservable(pr.save(pullRequest).toObservable());
sendToView(view -> updateTimeline(view, R.string.labels_added_successfully));
});
}
Aggregations