From feb02aba28c1c9087cb4eac86e8646918d413e95 Mon Sep 17 00:00:00 2001 From: Max Peterson Date: Fri, 19 Jun 2015 16:49:27 -0500 Subject: [PATCH] Refresh page button now refreshes the other pages as well after this page is refreshed --- web/stores/repos_store.dart | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/web/stores/repos_store.dart b/web/stores/repos_store.dart index b253ca0..c5e288d 100644 --- a/web/stores/repos_store.dart +++ b/web/stores/repos_store.dart @@ -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 futures = []; List 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(); }); } @@ -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) {