Skip to content

Commit d425f42

Browse files
author
tensor-programming
committed
fix auto-updater and github api
1 parent d526942 commit d425f42

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

lib/blocs/information_bloc.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ class InformationBloc {
1717
Stream<PackageInfo> get infoStream => _infoStream;
1818
Stream<GithubReleaseModel> get releases => _releases;
1919

20-
// BLoc that serves connectivity information and package information to the information drawer.
20+
// BLoc that serves package information to the information drawer.
2121
InformationBloc(this.packageInfo, this.api) {
2222
_infoStream = Observable.fromFuture(packageInfo).asBroadcastStream();
2323

24+
api.getReleases();
25+
2426
_releases = Observable.fromFuture(api.getReleases())
25-
.debounce(Duration(minutes: 5))
27+
.debounce(Duration(seconds: 1))
2628
.asBroadcastStream();
2729
}
2830
}

lib/components/list_page.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ class ListPage extends StatelessWidget {
3535
);
3636
}
3737

38-
infoBloc.releases.listen((releases) {
39-
infoBloc.infoStream.listen((pkInfo) {
40-
print(pkInfo.version);
41-
print(releases.tagName);
38+
infoBloc.infoStream.listen((pkInfo) {
39+
infoBloc.releases.listen((releases) {
4240
if (pkInfo.version.toString() != releases.tagName) {
4341
showDialog(
4442
context: context,

lib/model/githubApi.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ class GithubApi {
1313
Future<GithubReleaseModel> getReleases() async {
1414
List<GithubReleaseModel> items = [];
1515

16-
await _client
17-
.get(Uri.parse(_url))
18-
.then((Response res) => res.body)
19-
.then(json.decode)
20-
.then((j) => j.forEach((Map<String, dynamic> contribution) =>
21-
items.add(GithubReleaseModel.fromJson(contribution))));
22-
23-
return items.first;
16+
Response res = await _client.get(Uri.parse(_url));
17+
List map = json.decode(res.body);
18+
var x = map.map((gh) => GithubReleaseModel.fromJson(gh)).toList();
19+
return x.first;
2420
}
2521
}

lib/model/model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GithubReleaseModel {
5757

5858
GithubReleaseModel(this.tagName, this.htmlUrl);
5959

60-
GithubReleaseModel.fromJson(Map<String, dynamic> json)
60+
GithubReleaseModel.fromJson(Map json)
6161
: this.tagName = json['tag_name'],
6262
this.htmlUrl = json['html_url'];
6363
}

0 commit comments

Comments
 (0)