module Matterhorn.State.ChannelTopicWindow ( openChannelTopicWindow ) where import Prelude () import Matterhorn.Prelude import Lens.Micro.Platform ( (.=) ) import Network.Mattermost.Types ( TeamId ) import Matterhorn.Types import Matterhorn.State.Teams ( newChannelTopicDialog ) import Matterhorn.State.Channels ( getCurrentChannelTopic ) openChannelTopicWindow :: TeamId -> MH () openChannelTopicWindow :: TeamId -> MH () openChannelTopicWindow TeamId tId = do Maybe Text t <- TeamId -> MH (Maybe Text) getCurrentChannelTopic TeamId tId case Maybe Text t of Maybe Text Nothing -> () -> MH () forall a. a -> MH a forall (m :: * -> *) a. Monad m => a -> m a return () Just Text topic -> do TeamId -> Lens' ChatState TeamState csTeam(TeamId tId)((TeamState -> Identity TeamState) -> ChatState -> Identity ChatState) -> ((ChannelTopicDialogState -> Identity ChannelTopicDialogState) -> TeamState -> Identity TeamState) -> (ChannelTopicDialogState -> Identity ChannelTopicDialogState) -> ChatState -> Identity ChatState forall b c a. (b -> c) -> (a -> b) -> a -> c .(ChannelTopicDialogState -> Identity ChannelTopicDialogState) -> TeamState -> Identity TeamState Lens' TeamState ChannelTopicDialogState tsChannelTopicDialog ((ChannelTopicDialogState -> Identity ChannelTopicDialogState) -> ChatState -> Identity ChatState) -> ChannelTopicDialogState -> MH () forall s (m :: * -> *) a b. MonadState s m => ASetter s s a b -> b -> m () .= TeamId -> Text -> ChannelTopicDialogState newChannelTopicDialog TeamId tId Text topic TeamId -> Mode -> MH () pushMode TeamId tId Mode ChannelTopicWindow