1+ import client from 'apolloClient' ;
2+ import gql from 'graphql-tag' ;
13import EmptyState from 'modules/common/components/EmptyState' ;
24import routerUtils from 'modules/common/utils/router' ;
5+ import { mutations as notificationMutations } from 'modules/notifications/graphql' ;
36import React from 'react' ;
47import { Draggable , Droppable } from 'react-beautiful-dnd' ;
58import history from '../../../../browserHistory' ;
6- import { DropZone , EmptyContainer , Wrapper } from '../../styles/common' ;
9+ import {
10+ DropZone ,
11+ EmptyContainer ,
12+ ItemContainer ,
13+ Wrapper
14+ } from '../../styles/common' ;
715import { IItem , IOptions } from '../../types' ;
816
917type Props = {
@@ -26,12 +34,15 @@ type DraggableContainerProps = {
2634
2735class DraggableContainer extends React . Component <
2836 DraggableContainerProps ,
29- { isDragDisabled : boolean }
37+ { isDragDisabled : boolean ; hasNotified : boolean }
3038> {
3139 constructor ( props : DraggableContainerProps ) {
3240 super ( props ) ;
3341
34- this . state = { isDragDisabled : false } ;
42+ this . state = {
43+ isDragDisabled : false ,
44+ hasNotified : props . item . hasNotified === false ? false : true
45+ } ;
3546 }
3647
3748 onItemClick = ( ) => {
@@ -40,10 +51,19 @@ class DraggableContainer extends React.Component<
4051 this . setState ( { isDragDisabled : true } , ( ) => {
4152 routerUtils . setParams ( history , { itemId : item . _id } ) ;
4253 } ) ;
54+
55+ if ( ! this . state . hasNotified ) {
56+ client . mutate ( {
57+ mutation : gql ( notificationMutations . markAsRead ) ,
58+ variables : {
59+ contentTypeId : item . _id
60+ }
61+ } ) ;
62+ }
4363 } ;
4464
4565 beforePopupClose = ( ) => {
46- this . setState ( { isDragDisabled : false } ) ;
66+ this . setState ( { isDragDisabled : false , hasNotified : true } ) ;
4767 } ;
4868
4969 render ( ) {
@@ -59,16 +79,22 @@ class DraggableContainer extends React.Component<
5979 isDragDisabled = { isDragDisabled }
6080 >
6181 { ( dragProvided , dragSnapshot ) => (
62- < ItemComponent
63- key = { item . _id }
64- stageId = { stageId }
65- item = { item }
82+ < ItemContainer
6683 isDragging = { dragSnapshot . isDragging }
67- onClick = { this . onItemClick }
68- beforePopupClose = { this . beforePopupClose }
69- provided = { dragProvided }
70- options = { options }
71- />
84+ innerRef = { dragProvided . innerRef }
85+ hasNotified = { this . state . hasNotified }
86+ { ...dragProvided . draggableProps }
87+ { ...dragProvided . dragHandleProps }
88+ >
89+ < ItemComponent
90+ key = { item . _id }
91+ stageId = { stageId }
92+ item = { item }
93+ onClick = { this . onItemClick }
94+ beforePopupClose = { this . beforePopupClose }
95+ options = { options }
96+ />
97+ </ ItemContainer >
7298 ) }
7399 </ Draggable >
74100 ) ;
0 commit comments