Skip to content

Commit

Permalink
chore(Mattermost Plugin): Default to linked teams on new channels
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch committed Feb 28, 2025
1 parent 1f16c7c commit 4975b86
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions packages/mattermost-plugin/components/Sidepanel/SidePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import {useState} from 'react'
import graphql from 'babel-plugin-relay/macro'
import {useEffect, useState} from 'react'
import {useDispatch} from 'react-redux'
import {useLazyLoadQuery} from 'react-relay'
import ReactSelect from 'react-select'
import {SidePanelQuery} from '../../__generated__/SidePanelQuery.graphql'
import {useCurrentChannel} from '../../hooks/useCurrentChannel'
import {openLinkTeamModal, openStartActivityModal} from '../../reducers'
import ActiveMeetings from './ActiveMeetings'
import LinkedTeams from './LinkedTeams'
Expand All @@ -21,7 +25,26 @@ const panels = {
} as const

const SidePanel = () => {
const [activePanel, setActivePanel] = useState<keyof typeof panels>('teams')
const channel = useCurrentChannel()
const data = useLazyLoadQuery<SidePanelQuery>(
graphql`
query SidePanelQuery($channel: ID!) {
linkedTeamIds(channel: $channel)
}
`,
{
channel: channel?.id ?? ''
}
)
const {linkedTeamIds} = data

const [activePanel, setActivePanel] = useState<keyof typeof panels>('meetings')
useEffect(() => {
if (linkedTeamIds && linkedTeamIds.length === 0) {
setActivePanel('teams')
}
}, [linkedTeamIds])

const dispatch = useDispatch()

const handleClick = () => {
Expand Down

0 comments on commit 4975b86

Please sign in to comment.