use of com.meisolsson.githubsdk.service.reactions.ReactionService in project gh4a by slapperwan.
the class CommitDiffViewerActivity method loadReactionDetails.
@Override
public Single<List<Reaction>> loadReactionDetails(ReactionBar.Item item, boolean bypassCache) {
final CommitCommentWrapper comment = (CommitCommentWrapper) item;
final ReactionService service = ServiceFactory.get(ReactionService.class, bypassCache);
return ApiHelpers.PageIterator.toSingle(page -> service.getCommitCommentReactions(mRepoOwner, mRepoName, comment.comment.id(), page));
}
use of com.meisolsson.githubsdk.service.reactions.ReactionService in project gh4a by slapperwan.
the class IssueFragmentBase method addReaction.
@Override
public Single<Reaction> addReaction(ReactionBar.Item item, String content) {
ReactionService service = ServiceFactory.get(ReactionService.class, false);
ReactionRequest request = ReactionRequest.builder().content(content).build();
return service.createIssueReaction(mRepoOwner, mRepoName, mIssue.number(), request).map(ApiHelpers::throwOnFailure);
}
use of com.meisolsson.githubsdk.service.reactions.ReactionService in project gh4a by slapperwan.
the class CommitNoteAdapter method loadReactionDetails.
@Override
public Single<List<Reaction>> loadReactionDetails(ReactionBar.Item item, boolean bypassCache) {
final GitComment comment = ((ViewHolder) item).mBoundItem;
final ReactionService service = ServiceFactory.get(ReactionService.class, bypassCache);
return ApiHelpers.PageIterator.toSingle(page -> service.getCommitCommentReactions(mRepoOwner, mRepoName, comment.id(), page));
}
use of com.meisolsson.githubsdk.service.reactions.ReactionService in project gh4a by slapperwan.
the class ReactionBar method toggleReaction.
private static Single<Optional<Reaction>> toggleReaction(String content, long id, List<Reaction> existingDetails, Callback callback, Item item, ReactionDetailsCache cache) {
final Single<Optional<Reaction>> resultSingle;
if (id == 0) {
resultSingle = callback.addReaction(item, content).map(Optional::of);
} else {
ReactionService service = ServiceFactory.get(ReactionService.class, false);
resultSingle = service.deleteReaction(id).map(response -> Optional.absent());
}
return resultSingle.compose(RxUtils::doInBackground).doOnSuccess(reactionOpt -> {
if (reactionOpt.isPresent()) {
existingDetails.add(reactionOpt.get());
} else {
for (int i = 0; i < existingDetails.size(); i++) {
Reaction reaction = existingDetails.get(i);
if (reaction.id() == id) {
existingDetails.remove(i);
break;
}
}
}
cache.putEntry(item, existingDetails);
});
}
use of com.meisolsson.githubsdk.service.reactions.ReactionService in project gh4a by slapperwan.
the class ReviewFragment method addReaction.
@Override
public Single<Reaction> addReaction(GitHubCommentBase comment, String content) {
final ReactionService service = ServiceFactory.get(ReactionService.class, false);
final ReactionRequest request = ReactionRequest.builder().content(content).build();
final Single<Response<Reaction>> responseSingle = comment instanceof ReviewComment ? service.createPullRequestReviewCommentReaction(mRepoOwner, mRepoName, comment.id(), request) : service.createIssueCommentReaction(mRepoOwner, mRepoName, comment.id(), request);
return responseSingle.map(ApiHelpers::throwOnFailure);
}
Aggregations