From b1124361c29fe9875289e3a053684d6b685bfbfc Mon Sep 17 00:00:00 2001 From: seiyria Date: Sat, 31 Oct 2015 12:19:17 -0500 Subject: [PATCH] fix(logout): logging out should work in all browsers now closes #73 --- .../managers/tournamentManageCtrl.js | 8 +++--- src/js/controllers/managers/userManageCtrl.js | 26 ++++++++++--------- .../controllers/tournaments/inProgressCtrl.js | 1 - .../services/currents/currentTournaments.js | 14 +++++++--- src/js/services/managers/shareManagement.js | 4 +-- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/js/controllers/managers/tournamentManageCtrl.js b/src/js/controllers/managers/tournamentManageCtrl.js index d09a72e..a245a1a 100644 --- a/src/js/controllers/managers/tournamentManageCtrl.js +++ b/src/js/controllers/managers/tournamentManageCtrl.js @@ -110,11 +110,11 @@ site.controller('tournamentManageController', ($scope, $state, ShareToken, Sideb UserStatus.firebase.$loaded(() => { $scope.isMine = UserStatus.firebase.playerSetUid === authData.uid; - }); - CurrentTournaments.watch.then(null, null, () => { + CurrentTournaments.watch.then(null, null, () => { + $scope.loadTournaments(); + }); + $scope.loadTournaments(); }); - - $scope.loadTournaments(); }); \ No newline at end of file diff --git a/src/js/controllers/managers/userManageCtrl.js b/src/js/controllers/managers/userManageCtrl.js index fe03436..779955f 100644 --- a/src/js/controllers/managers/userManageCtrl.js +++ b/src/js/controllers/managers/userManageCtrl.js @@ -1,6 +1,6 @@ import site from '../../app'; -site.controller('userManageController', ($scope, $firebaseArray, $firebaseObject, FirebaseURL, ScoringFunctions, CurrentUsers, InputPrompt, UserStatus, CurrentPlayerBucket, CurrentTournaments, ShareManagement, SetManagement, SidebarManagement, EnsureLoggedIn, UserManagement, TournamentStatus, Toaster) => { +site.controller('userManageController', ($scope, $firebaseArray, $firebaseObject, Auth, FirebaseURL, ScoringFunctions, CurrentUsers, InputPrompt, UserStatus, CurrentPlayerBucket, CurrentTournaments, ShareManagement, SetManagement, SidebarManagement, EnsureLoggedIn, UserManagement, TournamentStatus, Toaster) => { SidebarManagement.hasSidebar = true; const authData = EnsureLoggedIn.check(); @@ -223,9 +223,6 @@ site.controller('userManageController', ($scope, $firebaseArray, $firebaseObject $scope.selected = []; }; - $scope.tournaments = CurrentTournaments.get(); - CurrentTournaments.watch.then(null, null, tournaments => $scope.tournaments = tournaments); - $scope.anyCompletedTournaments = () => _.any($scope.tournaments, t => t.status === TournamentStatus.COMPLETED); $scope.allTournamentGames = () => _.uniq($scope.tournaments, t => t.game); @@ -268,18 +265,23 @@ site.controller('userManageController', ($scope, $firebaseArray, $firebaseObject }; $scope.load = () => { - UserStatus.firebase.$loaded(() => { + Auth.ready.then(() => { + UserStatus.firebase.$loaded(() => { - if(!UserStatus.firebase.playerSet) { - $scope.changePlayerSet('default'); - } + if(!UserStatus.firebase.playerSet) { + $scope.changePlayerSet('default'); + } - $scope.setCurrentPlayerSet(CurrentUsers.get()); + $scope.setCurrentPlayerSet(CurrentUsers.get()); - $scope.isMine = UserStatus.firebase.playerSetUid === authData.uid; + $scope.isMine = UserStatus.firebase.playerSetUid === authData.uid; + + $scope.tournaments = CurrentTournaments.get(); + CurrentTournaments.watch.then(null, null, tournaments => $scope.tournaments = tournaments); + }); + $scope.loadAllLists(); + $scope.loadSharedWithMe(); }); - $scope.loadAllLists(); - $scope.loadSharedWithMe(); }; $scope.load(); diff --git a/src/js/controllers/tournaments/inProgressCtrl.js b/src/js/controllers/tournaments/inProgressCtrl.js index 540bce9..1de1d0a 100644 --- a/src/js/controllers/tournaments/inProgressCtrl.js +++ b/src/js/controllers/tournaments/inProgressCtrl.js @@ -20,7 +20,6 @@ site.controller('inProgressController', ($scope, $timeout, EnsureLoggedIn, Sideb const data = currentUsersInfo.users; if(!data.shareIDs) return; $scope.hasAccess = data && data.shareIDs[authData.uid] || defaultHasAccess(); - console.log(data, defaultHasAccess(), UserStatus.firebase.playerSetUid, authData); }); } diff --git a/src/js/services/currents/currentTournaments.js b/src/js/services/currents/currentTournaments.js index b4fe72a..346438e 100644 --- a/src/js/services/currents/currentTournaments.js +++ b/src/js/services/currents/currentTournaments.js @@ -1,13 +1,21 @@ import site from '../../app'; -site.service('CurrentTournaments', ($q, $firebaseArray, FirebaseURL, UserStatus) => { +site.service('CurrentTournaments', ($q, $firebaseArray, FirebaseURL, Auth, UserStatus, EnsureLoggedIn) => { + + EnsureLoggedIn.check(); + const defer = $q.defer(); - let ref = $firebaseArray(new Firebase(`${FirebaseURL}/users/${UserStatus.firebase.playerSetUid}/players/${UserStatus.firebase.playerSet}/tournaments`)); + let ref = {}; - UserStatus.firebase.$watch(() => { + const load = () => { ref = $firebaseArray(new Firebase(`${FirebaseURL}/users/${UserStatus.firebase.playerSetUid}/players/${UserStatus.firebase.playerSet}/tournaments`)); defer.notify(ref); + }; + + Auth.ready.then(() => { + UserStatus.firebase.$loaded(load); + UserStatus.firebase.$watch(load); }); return { diff --git a/src/js/services/managers/shareManagement.js b/src/js/services/managers/shareManagement.js index 27f5cec..277154f 100644 --- a/src/js/services/managers/shareManagement.js +++ b/src/js/services/managers/shareManagement.js @@ -2,9 +2,9 @@ import site from '../../app'; site.service('ShareManagement', (UserStatus, FirebaseURL, $firebaseArray) => { - const me = UserStatus.authData.uid; - const manageSorting = (oldSortsPlucked, newSorts, docId) => { + const me = UserStatus.authData.uid; + const newSortsPlucked = _.pluck(newSorts, 'uid'); const removals = _.difference(oldSortsPlucked, newSortsPlucked); const additions = _.difference(newSortsPlucked, oldSortsPlucked);