-
+
{{ $t("loading") }}
@@ -76,6 +72,7 @@ export default {
query GetMe {
me {
uid
+ eaInvited
}
}
`,
diff --git a/helpers/apollo.ts b/helpers/apollo.ts
index 74ada4b09..1e3dcf2d5 100644
--- a/helpers/apollo.ts
+++ b/helpers/apollo.ts
@@ -4,15 +4,27 @@ import { setContext } from "@apollo/client/link/context"
import { fb } from "./fb"
import { getMainDefinition } from "@apollo/client/utilities"
+let authToken: String | null = null
+
+export function registerApolloAuthUpdate() {
+ fb.idToken$.subscribe((token: String | null) => {
+ console.log(token, "from sub")
+
+ authToken = token
+ })
+}
+
/**
* Injects auth token if available
*/
const authLink = setContext((_, { headers }) => {
- if (fb.idToken) {
+ console.log(authToken)
+
+ if (authToken) {
return {
headers: {
...headers,
- authorization: `Bearer ${fb.idToken}`,
+ authorization: `Bearer ${authToken}`,
},
}
} else {
@@ -38,11 +50,11 @@ const wsLink = new WebSocketLink({
reconnect: true,
lazy: true,
connectionParams: () => {
- if (fb.idToken) {
+ if (authToken) {
return {}
} else {
return {
- authorization: `Bearer ${fb.idToken}`,
+ authorization: `Bearer ${authToken}`,
}
}
},
diff --git a/helpers/teams/BackendUserInfo.ts b/helpers/teams/BackendUserInfo.ts
index 6e49ec0ae..71c197224 100644
--- a/helpers/teams/BackendUserInfo.ts
+++ b/helpers/teams/BackendUserInfo.ts
@@ -42,12 +42,14 @@ export const currentUserInfo$ = new BehaviorSubject(null)
/**
* Initializes the currenUserInfo$ view and sets up its update mechanism
*/
-export function initUserInfo() {
- updateUserInfo()
+export async function initUserInfo() {
+ await updateUserInfo()
+ console.log("updated")
- fb.idToken$.subscribe(token => {
+ fb.idToken$.subscribe((token) => {
if (token) {
updateUserInfo()
+ console.log(token, "updateUserInfo")
} else {
currentUserInfo$.next(null)
}
@@ -63,22 +65,24 @@ async function updateUserInfo() {
query: gql`
query GetUserInfo {
me {
- uid,
- displayName,
- email,
- photoURL,
+ uid
+ displayName
+ email
+ photoURL
eaInvited
}
}
- `
+ `,
})
-
+
+ console.log(data)
+
currentUserInfo$.next({
uid: data.me.uid,
displayName: data.me.displayName,
email: data.me.email,
- photoURL : data.me.photoURL,
- eaInvited: data.me.eaInvited
+ photoURL: data.me.photoURL,
+ eaInvited: data.me.eaInvited,
})
} catch (e) {
currentUserInfo$.next(null)
diff --git a/helpers/teams/utils.js b/helpers/teams/utils.js
index a214c6a6f..fa6467c9d 100644
--- a/helpers/teams/utils.js
+++ b/helpers/teams/utils.js
@@ -32,7 +32,6 @@ export async function getLiveTeamMembersList(apollo, teamID) {
},
})
- debugger
subject.next(data.team.members)
const addedSub = apollo
@@ -53,6 +52,7 @@ export async function getLiveTeamMembersList(apollo, teamID) {
},
})
.subscribe(({ data }) => {
+ console.log(data)
subject.next([...subject.value, data.teamMemberAdded])
})
diff --git a/layouts/default.vue b/layouts/default.vue
index 63a0a411a..c09072f7a 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -17,9 +17,12 @@
import { setupLocalPersistence } from "~/newstore/localpersistence"
import { performMigrations } from "~/helpers/migrations"
import { initUserInfo } from "~/helpers/teams/BackendUserInfo"
+import { registerApolloAuthUpdate } from "~/helpers/apollo"
export default {
beforeMount() {
+ registerApolloAuthUpdate()
+
let color = localStorage.getItem("THEME_COLOR") || "green"
document.documentElement.setAttribute("data-accent", color)
},
diff --git a/pages/settings.vue b/pages/settings.vue
index 38cb9b26f..6e95b0fa5 100644
--- a/pages/settings.vue
+++ b/pages/settings.vue
@@ -1,6 +1,6 @@
-
+
@@ -202,6 +202,7 @@ import {
defaultSettings,
} from "~/newstore/settings"
import type { KeysMatching } from "~/types/ts-utils"
+import { currentUserInfo$ } from "~/helpers/teams/BackendUserInfo"
import Vue from "vue"
@@ -243,6 +244,9 @@ export default Vue.extend({
SYNC_COLLECTIONS: getSettingSubject("syncCollections"),
SYNC_ENVIRONMENTS: getSettingSubject("syncEnvironments"),
SYNC_HISTORY: getSettingSubject("syncHistory"),
+
+ // Teams feature flag
+ currentUser: currentUserInfo$,
}
},
watch: {