Skip to content

Commit

Permalink
Let Relay do the update
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch committed Jan 14, 2025
1 parent 1d084e0 commit 0707257
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
17 changes: 4 additions & 13 deletions packages/client/mutations/CreateMassInvitationMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import {CreateMassInvitationMutation as TCreateMassInvitationMutation} from '../
import {StandardMutation} from '../types/relayMutations'

graphql`
fragment CreateMassInvitationMutation_team on CreateMassInvitationSuccess {
fragment CreateMassInvitationMutation_team on CreateMassInvitationSuccess
@argumentDefinitions(meetingId: {type: "ID", defaultValue: null}) {
team {
massInvitation {
massInvitation(meetingId: $meetingId) {
id
expiration
meetingId
Expand All @@ -23,7 +24,7 @@ const mutation = graphql`
message
}
}
...CreateMassInvitationMutation_team @relay(mask: false)
...CreateMassInvitationMutation_team @arguments(meetingId: $meetingId)
}
}
`
Expand All @@ -35,16 +36,6 @@ const CreateMassInvitationMutation: StandardMutation<TCreateMassInvitationMutati
) => {
return commitMutation<TCreateMassInvitationMutation>(atmosphere, {
mutation,
updater: (store) => {
const payload = store.getRootField('createMassInvitation')
if (!payload) return
const team = payload.getLinkedRecord('team')
const massInvitation = team.getLinkedRecord('massInvitation')
const meetingId = massInvitation.getValue('meetingId')
if (!meetingId) return
// satisfy the need of the query
team.setLinkedRecord(massInvitation, 'massInvitation', {meetingId})
},
variables,
onCompleted,
onError
Expand Down
3 changes: 3 additions & 0 deletions packages/mattermost-plugin/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ module.exports = {
//contentBase: path.join(__dirname, "dist"),
port: 3002,
},
watchOptions: {
ignored: /node_modules/
},
output: {
publicPath: "auto",
},
Expand Down
4 changes: 3 additions & 1 deletion packages/server/graphql/types/Team.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ const Team: GraphQLObjectType = new GraphQLObjectType<ITeam, GQLContext>({
.load(teamMemberId)
const matchingInvitation = invitationTokens.find((token) => token.meetingId === meetingId)
// if the token is valid, return it
if ((matchingInvitation?.expiration ?? new Date(0)) > new Date()) return matchingInvitation
if ((matchingInvitation?.expiration ?? new Date(0)) > new Date()) {
return matchingInvitation
}

// if there is no matching token, let's use the opportunity to clean up old tokens
if (invitationTokens.length > 0) {
Expand Down

0 comments on commit 0707257

Please sign in to comment.