Skip to content

Commit e9e3603

Browse files
author
rtucker-mozilla
authored
Merge pull request #645 from rtucker-mozilla/master
Looking to reduce calls to the api for unauthenticated users
2 parents d4fc89c + 868f386 commit e9e3603

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/components/access_group/AccessGroupInvitationNotification.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ export default {
8181
path: 'selfInvitations/get',
8282
});
8383
84-
return data.map((invite) => new GroupInvitationViewModel(invite));
84+
if(data.map){
85+
return data.map((invite) => new GroupInvitationViewModel(invite));
86+
} else {
87+
return {}
88+
}
89+
8590
},
8691
async acceptInvitation(currentInvitation) {
8792
return await this.accessGroupApi.execute({

src/store/index.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import user from './user.store';
88
import scope from './scope.store';
99
import features from './features.store';
1010

11+
let shouldFetch = true;
12+
1113
async function fetchUser(commit) {
14+
if (shouldFetch === false){
15+
return
16+
}
1217
try {
1318
const fetchPolicy = 'network-only';
1419
const { data } = await client.query({
@@ -19,14 +24,21 @@ async function fetchUser(commit) {
1924
commit('setUser', data.profile);
2025
return true;
2126
} catch (e) {
22-
const {
23-
graphQLErrors: [{ message }],
24-
} = e;
25-
if (message === 'wait_for_profile') {
26-
console.log('creating');
27-
}
28-
commit('setUser', { loggedIn: true });
29-
return false;
27+
try {
28+
const {
29+
graphQLErrors: [{ message }],
30+
} = e;
31+
if (message === 'wait_for_profile') {
32+
console.log('creating');
33+
}
34+
commit('setUser', { loggedIn: true });
35+
return false;
36+
}
37+
catch(e) {
38+
// Probably getting a 403 for authentication
39+
shouldFetch = false
40+
return false
41+
}
3042
}
3143
}
3244

@@ -101,4 +113,4 @@ export async function resolvePromisesSerially(promises, resolvers) {
101113
console.error(e.message);
102114
throw new Error(e.message);
103115
}
104-
}
116+
}

0 commit comments

Comments
 (0)