Skip to content

Commit

Permalink
Bug Fix with Pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Aug 28, 2014
1 parent 8873538 commit b688069
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/common/github.dart
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ class GitHub {

var url = new StringBuffer();

if (path.startsWith("http")) {
if (path.startsWith("http://") || path.startsWith("https://")) {
url.write(path);
url.write(queryString);
} else {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/common/pagination.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class PaginationHelper<T> {
PaginationHelper(this.github) : responses = [], completer = new Completer<List<http.Response>>();

Future<List<http.Response>> fetch(String method, String path, {int pages, Map<String, String> headers, Map<String, dynamic> params, String body}) {
if (headers == null) headers = {};
Future<http.Response> actualFetch(String realPath) {
return github.request(method, realPath, headers: headers, params: params, body: body);
}
Expand Down Expand Up @@ -52,6 +53,7 @@ class PaginationHelper<T> {
}

Stream<http.Response> fetchStreamed(String method, String path, {int pages, bool reverse: false, int start, Map<String, String> headers, Map<String, dynamic> params, String body}) {
if (headers == null) headers = {};
var controller = new StreamController.broadcast();

Future<http.Response> actualFetch(String realPath, [bool first = false]) {
Expand Down Expand Up @@ -111,6 +113,7 @@ class PaginationHelper<T> {
}

Stream<T> objects(String method, String path, JSONConverter converter, {int pages, bool reverse: false, int start, Map<String, String> headers, Map<String, dynamic> params, String body}) {
if (headers == null) headers = {};
headers.putIfAbsent("Accept", () => "application/vnd.github.v3+json");
var controller = new StreamController();
fetchStreamed(method, path, pages: pages, start: start, reverse: reverse, headers: headers, params: params, body: body).listen((response) {
Expand Down

0 comments on commit b688069

Please sign in to comment.