Skip to content

Commit

Permalink
chore(Mattermost Plugin): Poll active meetings (#10950)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch authored Mar 4, 2025
1 parent 17085b8 commit 8912e23
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
58 changes: 32 additions & 26 deletions packages/mattermost-plugin/Atmosphere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,40 @@ type State = {
}

const fetchGraphQL = (state: State) => (params: RequestParameters, variables: Variables) => {
const {serverUrl, store} = state
const authToken = getAuthToken(store.getState())
const response = fetch(
serverUrl + '/graphql',
Client4.getOptions({
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
'x-application-authorization': authToken ? `Bearer ${authToken}` : ''
},
body: JSON.stringify({
type: 'start',
payload: {
documentId: params.id,
query: params.text,
variables
}
return Observable.create((sink) => {
const {serverUrl, store} = state
const authToken = getAuthToken(store.getState())
const response = fetch(
serverUrl + '/graphql',
Client4.getOptions({
method: 'POST',
headers: {
accept: 'application/json',
'content-type': 'application/json',
'x-application-authorization': authToken ? `Bearer ${authToken}` : ''
},
body: JSON.stringify({
type: 'start',
payload: {
documentId: params.id,
query: params.text,
variables
}
})
})
})
)
)

return Observable.from(
response.then(async (data) => {
const json = await data.json()
return json.payload
})
)
response
.then(async (data) => {
const json = await data.json()
sink.next(json.payload)
sink.complete()
})
.catch((error) => {
sink.error(error)
sink.complete()
})
})
}

const login = (state: State) => async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const ActiveMeetings = () => {
`,
{
channel: channel?.id ?? ''
},
{
networkCacheConfig: {
force: true,
poll: 15000
}
}
)
const {viewer, linkedTeamIds} = data
Expand Down

0 comments on commit 8912e23

Please sign in to comment.