@@ -39,10 +39,11 @@ import { ImageV2 } from './reusables/SharedStylingV2';
3939import Tooltip from './reusables/tooltip/Tooltip' ;
4040import UpdateChannelTooltipContent from './UpdateChannelTooltipContent' ;
4141import VerifiedTooltipContent from './VerifiedTooltipContent' ;
42+ import { setAllowNotifModalVisibility } from 'redux/slices/modalSlice' ;
4243
4344// Internal Configs
4445import APP_PATHS from 'config/AppPaths' ;
45- import { addresses , appConfig , CHAIN_DETAILS , ALLOW_NOTIF_MODAL } from 'config/index.js' ;
46+ import { addresses , appConfig , CHAIN_DETAILS , ALLOW_NOTIF_MODAL_LAST_TIMESTAMP } from 'config/index.js' ;
4647import { IPFSGateway } from 'helpers/IpfsHelper' ;
4748import { checkPermission } from 'helpers/channel/allowNotification' ;
4849
@@ -60,6 +61,7 @@ function ViewChannelItem({ channelObjectProp, loadTeaser, playTeaser, minimal, p
6061 ( state ) => state . contracts
6162 ) ;
6263 const { canVerify, channelDetails, coreChannelAdmin } = useSelector ( ( state ) => state . admin ) ;
64+ const { isAllowNotifModalVisible } = useSelector ( ( state ) => state . modal ) ;
6365 const {
6466 channelsCache,
6567 CHANNEL_BLACKLIST ,
@@ -87,7 +89,7 @@ function ViewChannelItem({ channelObjectProp, loadTeaser, playTeaser, minimal, p
8789 const [ channelObjectFromHash , setChannelObjectFromHash ] = React . useState ( { } ) ;
8890 const [ channelObjectStartBlock , setChannelObjectStartBlock ] = React . useState ( { } ) ;
8991 const [ showChannelChangedWarning , setShowChannelChangedWarning ] = React . useState ( false ) ;
90- const [ showAllowNotification , setShowAllowNotification ] = useState ( false ) ;
92+ // const [isAllowNotifModalVisible, setAllowNotifModalVisibility ] = useState(false);
9193
9294
9395 const isVerified = channelObject . verified_status ;
@@ -109,11 +111,11 @@ function ViewChannelItem({ channelObjectProp, loadTeaser, playTeaser, minimal, p
109111 } , [ subscriptionStatus ] ) ;
110112
111113 useEffect ( ( ) => {
112- if ( showAllowNotification )
114+ if ( isAllowNotifModalVisible )
113115 setTimeout ( ( ) => {
114- setShowAllowNotification ( false ) ;
116+ dispatch ( setAllowNotifModalVisibility ( { flag : false } ) ) ;
115117 } , 10000 ) ;
116- } , [ showAllowNotification ] ) ;
118+ } , [ isAllowNotifModalVisible ] ) ;
117119
118120 useEffect ( ( ) => {
119121 setIsPushAdmin ( pushAdminAddress == account ) ;
@@ -417,19 +419,19 @@ function ViewChannelItem({ channelObjectProp, loadTeaser, playTeaser, minimal, p
417419 the modal was last opened 24 hours before
418420 */
419421 if ( checkPermission ( ) === 'pending' ) {
420- let lastTime = localStorage . getItem ( ALLOW_NOTIF_MODAL ) ;
422+ let lastTime = localStorage . getItem ( ALLOW_NOTIF_MODAL_LAST_TIMESTAMP ) ;
421423 let today = new Date ( ) . getTime ( ) + ( 1 * 24 * 60 * 60 * 1000 ) ;
422424 if ( lastTime ) {
423425 lastTime = parseInt ( lastTime ) ;
424426 if ( lastTime >= today ) {
425- setShowAllowNotification ( true ) ;
427+ dispatch ( setAllowNotifModalVisibility ( { flag : true } ) ) ;
426428 }
427429 }
428430 else {
429- setShowAllowNotification ( true ) ;
431+ dispatch ( setAllowNotifModalVisibility ( { flag : true } ) ) ;
430432 }
431433 //sets the recent opened time in localstorage.
432- localStorage . setItem ( ALLOW_NOTIF_MODAL , today ) ;
434+ localStorage . setItem ( ALLOW_NOTIF_MODAL_LAST_TIMESTAMP , today ) ;
433435 }
434436
435437 }
@@ -1055,8 +1057,10 @@ function ViewChannelItem({ channelObjectProp, loadTeaser, playTeaser, minimal, p
10551057 />
10561058 ) }
10571059 { /* modal to allow notification */ }
1058- { showAllowNotification &&
1059- < AllowNotificationModal onModalClose = { ( ) => setShowAllowNotification ( false ) } />
1060+ { isAllowNotifModalVisible &&
1061+ < AllowNotificationModal onModalClose = { ( ) =>
1062+ dispatch ( setAllowNotifModalVisibility ( { flag : false } ) ) }
1063+ />
10601064 }
10611065 </ Container >
10621066 ) ;
0 commit comments