Mutate the labels on links when setting them so they are reflected in UI
This commit is contained in:
@ -109,6 +109,7 @@ export function ArticleActionsMenu(props: ArticleActionsMenuProps): JSX.Element
|
||||
}
|
||||
>
|
||||
<SetLabelsControl
|
||||
article={props.article}
|
||||
linkId={props.article.linkId}
|
||||
labels={props.article.labels}
|
||||
articleActionHandler={props.articleActionHandler}
|
||||
|
||||
@ -14,10 +14,12 @@ import { createLabelMutation } from '../../../lib/networking/mutations/createLab
|
||||
import { showErrorToast, showSuccessToast } from '../../../lib/toastHelpers'
|
||||
import { randomLabelColorHex } from '../../../utils/settings-page/labels/labelColorObjects'
|
||||
import { useRouter } from 'next/router'
|
||||
import { ArticleAttributes } from '../../../lib/networking/queries/useGetArticleQuery'
|
||||
|
||||
type SetLabelsControlProps = {
|
||||
linkId: string
|
||||
labels: Label[] | undefined
|
||||
article?: ArticleAttributes
|
||||
articleActionHandler: (action: string, arg?: unknown) => void
|
||||
}
|
||||
|
||||
@ -215,7 +217,9 @@ export function SetLabelsControl(props: SetLabelsControlProps): JSX.Element {
|
||||
newSelectedLabels.map((label) => label.id)
|
||||
)
|
||||
|
||||
// props.article.labels = result
|
||||
if (props.article) {
|
||||
props.article.labels = result
|
||||
}
|
||||
props.articleActionHandler('refreshLabels', result)
|
||||
|
||||
revalidate()
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { Label } from '../../../lib/networking/fragments/labelFragment'
|
||||
import { ArticleAttributes } from '../../../lib/networking/queries/useGetArticleQuery'
|
||||
import { Button } from '../../elements/Button'
|
||||
import { CrossIcon } from '../../elements/images/CrossIcon'
|
||||
import { HStack, VStack } from '../../elements/LayoutPrimitives'
|
||||
@ -14,6 +15,7 @@ import { SetLabelsControl } from './SetLabelsControl'
|
||||
type SetLabelsModalProps = {
|
||||
linkId: string
|
||||
labels: Label[] | undefined
|
||||
article?: ArticleAttributes
|
||||
onOpenChange: (open: boolean) => void
|
||||
articleActionHandler: (action: string, arg?: unknown) => void
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user