Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
Refresh page button now refreshes the other pages as well after this …
Browse files Browse the repository at this point in the history
…page is refreshed
  • Loading branch information
maxwellpeterson-wf committed Jun 19, 2015
1 parent cad505d commit feb02ab
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions web/stores/repos_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,25 @@ class ReposStore extends Store {
}

Future initializeCurrentPageRepos() {
var currentPageRepos = _storage.getRepos(_storage.currentPage);
return initializePageRepos(_storage.currentPage);
}

Future initializePageRepos(String pageName) {
var repoNames = _storage.getRepos(pageName);
List<Future> futures = [];
List<Repository> repos = [];
currentPageRepos.forEach((repoName) {
repoNames.forEach((repoName) {
var repo = new Repository(repoName, _actions);
repos.add(repo);
futures.add(repo.initializeData());
});
// Trigger immediately, and also when the data is done loading
_allRepos[_storage.currentPage] = repos;
trigger();
_allRepos[pageName] = repos;
if (pageName == _storage.currentPage) trigger();

return Future.wait(futures).then((futures) {
_allRepos[_storage.currentPage] = repos;
trigger();
_allRepos[pageName] = repos;
if (pageName == _storage.currentPage) trigger();
});
}

Expand Down Expand Up @@ -104,8 +108,14 @@ class ReposStore extends Store {
trigger();
}

onRefreshPage(String pageName) {
initializeCurrentPageRepos();
onRefreshPage(String pageName) async {
await initializeCurrentPageRepos();
for (int i=0; i < pageNames.length; i++) {
String name = pageNames[i];
if (name != _storage.currentPage) {
await initializePageRepos(name);
}
}
}

onAddPage(String pageName) {
Expand Down

0 comments on commit feb02ab

Please sign in to comment.