Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(standups): Auto-open response discussion based on query param #7546

Merged
merged 2 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/client/components/ResponseMentioned.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const ResponseMentioned = (props: Props) => {
fragment ResponseMentioned_notification on NotifyResponseMentioned {
...NotificationTemplate_notification
response {
id
user {
picture
preferredName
Expand All @@ -37,7 +38,7 @@ const ResponseMentioned = (props: Props) => {
const {id: meetingId, name: meetingName} = meeting
const goThere = () => {
// :TODO: (jmtaber129): Link directly to card once we support that.
history.push(`/meet/${meetingId}`)
history.push(`/meet/${meetingId}/responses?responseId=${encodeURIComponent(response.id)}`)
}

// :TODO: (jmtaber129): Show mention preview.
Expand Down
28 changes: 25 additions & 3 deletions packages/client/components/TeamPromptMeeting.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import styled from '@emotion/styled'
import graphql from 'babel-plugin-relay/macro'
import React, {Suspense, useMemo} from 'react'
import {useFragment} from 'react-relay'
import React, {Suspense, useEffect, useMemo} from 'react'
import {commitLocalUpdate, useFragment} from 'react-relay'
import {useHistory} from 'react-router'
import useAtmosphere from '~/hooks/useAtmosphere'
import useMeeting from '~/hooks/useMeeting'
import useTransition from '~/hooks/useTransition'
Expand Down Expand Up @@ -71,6 +72,7 @@ const TeamPromptMeeting = (props: Props) => {
...TeamPromptDiscussionDrawer_meeting
...TeamPromptEditablePrompt_meeting
...TeamPromptMeetingStatus_meeting
id
isRightDrawerOpen
phases {
... on TeamPromptResponsesPhase {
Expand All @@ -81,6 +83,7 @@ const TeamPromptMeeting = (props: Props) => {
userId
}
response {
id
plaintextContent
createdAt
}
Expand Down Expand Up @@ -126,7 +129,26 @@ const TeamPromptMeeting = (props: Props) => {
}, [phase])
const transitioningStages = useTransition(stages)
const {safeRoute, isDesktop} = useMeeting(meeting)
const {isRightDrawerOpen} = meeting
const history = useHistory()
const {isRightDrawerOpen, id: meetingId} = meeting
useEffect(() => {
const params = new URLSearchParams(history.location.search)
if (!params.get('responseId')) {
return
}

const stage = stages.find((stage) => stage.response?.id === params.get('responseId'))
if (!stage) {
return
}

commitLocalUpdate(atmosphere, (store) => {
const meetingProxy = store.get(meetingId)
if (!meetingProxy) return
meetingProxy.setValue(stage.id, 'localStageId')
meetingProxy.setValue(true, 'isRightDrawerOpen')
})
}, [])
if (!safeRoute) return null

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const EmailResponseMentioned = (props: Props) => {
fragment EmailResponseMentioned_notification on NotifyResponseMentioned {
...EmailNotificationTemplate_notification
response {
id
user {
rasterPicture
preferredName
Expand All @@ -36,8 +37,13 @@ const EmailResponseMentioned = (props: Props) => {

const {id: meetingId, name: meetingName} = meeting

const linkUrl = makeAppURL(appOrigin, `/meet/${meetingId}`, {
searchParams: notificationSummaryUrlParams
// :TRICKY: If the URL we navigate to isn't the full URL w/ phase name (e.g. just
// '/meet/<meetingId>'), the URL will be overwritten and the 'responseId' will be lost.
const linkUrl = makeAppURL(appOrigin, `/meet/${meetingId}/responses`, {
searchParams: {
...notificationSummaryUrlParams,
responseId: response.id
}
})

// :TODO: (jmtaber129): Show mention preview.
Expand Down
1 change: 1 addition & 0 deletions packages/client/utils/makeAppURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface Options {
utm_medium: string
utm_campaign: string
openNotifs?: string
responseId?: string
}
}

Expand Down