1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-21 13:38:56 +02:00

adding some selectors to the create new cards modal

This commit is contained in:
Benjamin Cooke 2023-03-07 15:05:01 -05:00
parent 2a14d8a41d
commit 1f6a500b21
3 changed files with 21 additions and 5 deletions

View File

@ -9,10 +9,10 @@ import {Card} from '../blocks/card'
import octoClient from '../octoClient'
import mutator from '../mutator'
import {getCard} from '../store/cards'
import {getCardComments} from '../store/comments'
import {getCardComments, getCardComments1} from '../store/comments'
import {getCardContents} from '../store/contents'
import {useAppDispatch, useAppSelector} from '../store/hooks'
import {getCardAttachments, updateAttachments, updateUploadPrecent} from '../store/attachments'
import {getCardAttachments, getCardAttachments1, updateAttachments, updateUploadPrecent} from '../store/attachments'
import TelemetryClient, {TelemetryActions, TelemetryCategory} from '../telemetry/telemetryClient'
import {Utils} from '../utils'
import CompassIcon from '../widgets/icons/compassIcon'
@ -39,6 +39,7 @@ import Dialog from './dialog'
import './cardDialog.scss'
import CardActionsMenu from './cardActionsMenu/cardActionsMenu'
import {RootState} from '../store'
type Props = {
board: Board
@ -55,8 +56,8 @@ const CardDialog = (props: Props): JSX.Element => {
const {board, activeView, cards, views} = props
const card = useAppSelector(getCard(props.cardId))
const contents = useAppSelector(getCardContents(props.cardId))
const comments = useAppSelector(getCardComments(props.cardId))
const attachments = useAppSelector(getCardAttachments(props.cardId))
const comments = useAppSelector((state: RootState) => getCardComments1(state, props.cardId))
const attachments = useAppSelector((state: RootState) => getCardAttachments1(state, props.cardId))
const clientConfig = useAppSelector(getClientConfig)
const intl = useIntl()
const dispatch = useAppDispatch()

View File

@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {createSlice, PayloadAction} from '@reduxjs/toolkit'
import {createSelector, createSlice, PayloadAction} from '@reduxjs/toolkit'
import {AttachmentBlock} from '../blocks/attachmentBlock'
@ -90,3 +90,10 @@ export function getUploadPercent(blockId: string): (state: RootState) => number
return (state.attachments.attachments[blockId].uploadingPercent)
}
}
export const getCardAttachments1: (state: RootState, cardId: string) => AttachmentBlock[] = createSelector(
(state: RootState, cardId: string) => state.attachments.attachmentsByCard[cardId],
(attachments) => {
return attachments || []
},
)

View File

@ -86,6 +86,14 @@ export function getCardComments(cardId: string): (state: RootState) => CommentBl
}
}
export const getCardComments1: (state: RootState, cardId: string) => CommentBlock[] = createSelector(
(state: RootState, cardId: string) => state.comments?.commentsByCard[cardId],
(comments) => {
console.log(comments)
return comments || []
},
)
export function getLastCardComment(cardId: string): (state: RootState) => CommentBlock|undefined {
return (state: RootState): CommentBlock|undefined => {
const comments = state.comments?.commentsByCard && state.comments.commentsByCard[cardId]