"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "helpers/teams/TeamMemberAdapter.ts" between
hoppscotch-2.0.0.tar.gz and hoppscotch-2.1.0.tar.gz

About: Hoppscotch is a light-weight, web based API development suite.

TeamMemberAdapter.ts  (hoppscotch-2.0.0):TeamMemberAdapter.ts  (hoppscotch-2.1.0)
import { BehaviorSubject } from "rxjs" import { BehaviorSubject } from "rxjs"
import gql from "graphql-tag" import gql from "graphql-tag"
import cloneDeep from "lodash/cloneDeep" import cloneDeep from "lodash/cloneDeep"
import * as Apollo from "@apollo/client/core" import * as Apollo from "@apollo/client/core"
import { apolloClient } from "~/helpers/apollo" import { apolloClient } from "~/helpers/apollo"
interface TeamsTeamMember { export interface TeamsTeamMember {
membershipID: string membershipID: string
user: { user: {
uid: string uid: string
email: string email: string
} }
role: "OWNER" | "EDITOR" | "VIEWER" role: "OWNER" | "EDITOR" | "VIEWER"
} }
export default class TeamMemberAdapter { export default class TeamMemberAdapter {
members$: BehaviorSubject<TeamsTeamMember[]> members$: BehaviorSubject<TeamsTeamMember[]>
skipping to change at line 59 skipping to change at line 59
this.registerSubscriptions() this.registerSubscriptions()
} }
private async loadTeamMembers(): Promise<void> { private async loadTeamMembers(): Promise<void> {
const result: TeamsTeamMember[] = [] const result: TeamsTeamMember[] = []
let cursor: string | null = null let cursor: string | null = null
while (true) { while (true) {
const response: Apollo.ApolloQueryResult<any> = await apolloClient.query({ const response: Apollo.ApolloQueryResult<any> = await apolloClient.query({
query: gql` query: gql`
query GetTeamMembers($teamID: String!, $cursor: String) { query GetTeamMembers($teamID: ID!, $cursor: ID) {
team(teamID: $teamID) { team(teamID: $teamID) {
members(cursor: $cursor) { members(cursor: $cursor) {
membershipID membershipID
user { user {
uid uid
email email
} }
role role
} }
} }
skipping to change at line 95 skipping to change at line 95
} }
} }
this.members$.next(result) this.members$.next(result)
} }
private registerSubscriptions() { private registerSubscriptions() {
this.teamMemberAdded$ = apolloClient this.teamMemberAdded$ = apolloClient
.subscribe({ .subscribe({
query: gql` query: gql`
subscription TeamMemberAdded($teamID: String!) { subscription TeamMemberAdded($teamID: ID!) {
teamMemberAdded(teamID: $teamID) { teamMemberAdded(teamID: $teamID) {
user { user {
uid uid
email email
} }
role role
} }
} }
`, `,
variables: { variables: {
teamID: this.teamID, teamID: this.teamID,
}, },
}) })
.subscribe(({ data }) => { .subscribe(({ data }) => {
this.members$.next([...this.members$.value, data.teamMemberAdded]) this.members$.next([...this.members$.value, data.teamMemberAdded])
}) })
this.teamMemberRemoved$ = apolloClient this.teamMemberRemoved$ = apolloClient
.subscribe({ .subscribe({
query: gql` query: gql`
subscription TeamMemberRemoved($teamID: String!) { subscription TeamMemberRemoved($teamID: ID!) {
teamMemberRemoved(teamID: $teamID) teamMemberRemoved(teamID: $teamID)
} }
`, `,
variables: { variables: {
teamID: this.teamID, teamID: this.teamID,
}, },
}) })
.subscribe(({ data }) => { .subscribe(({ data }) => {
this.members$.next( this.members$.next(
this.members$.value.filter( this.members$.value.filter(
(el) => el.user.uid !== data.teamMemberRemoved (el) => el.user.uid !== data.teamMemberRemoved
) )
) )
}) })
this.teamMemberUpdated$ = apolloClient this.teamMemberUpdated$ = apolloClient
.subscribe({ .subscribe({
query: gql` query: gql`
subscription TeamMemberUpdated($teamID: String!) { subscription TeamMemberUpdated($teamID: ID!) {
teamMemberUpdated(teamID: $teamID) { teamMemberUpdated(teamID: $teamID) {
user { user {
uid uid
email email
} }
role role
} }
} }
`, `,
variables: { variables: {
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)