File tree 1 file changed +19
-3
lines changed
src/app/layouts/default/lower-sticky-note
1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { usePutAway , useStickyData } from '../shared.js' ;
3
3
import JITLoad from '~/helpers/jit-load' ;
4
+ import Cookies from 'js-cookie' ;
5
+
6
+ const cookieKey = 'lower-sticky-note-closed' ;
4
7
5
8
export default function LowerStickyNote ( ) {
6
9
const stickyData = useStickyData ( ) ;
7
10
const [ closed , PutAway ] = usePutAway ( ) ;
8
- const shouldNotDisplay = ! stickyData || closed ||
9
- stickyData . mode !== 'banner' ;
11
+ const shouldNotDisplay =
12
+ ! stickyData ||
13
+ closed ||
14
+ stickyData ?. mode !== 'banner' ||
15
+ Boolean ( Cookies . get ( cookieKey ) ) ;
16
+ const hasDisplayed = React . useRef ( false ) ;
17
+
18
+ React . useEffect ( ( ) => {
19
+ if ( hasDisplayed . current && closed ) {
20
+ Cookies . set ( cookieKey , 'true' , { expires : 7 } ) ;
21
+ }
22
+ } , [ closed ] ) ;
10
23
11
24
if ( shouldNotDisplay ) {
12
25
return null ;
13
26
}
14
27
28
+ hasDisplayed . current = true ;
29
+
15
30
return (
16
31
< JITLoad
17
- importFn = { ( ) => import ( './lsn-content' ) } stickyData = { stickyData }
32
+ importFn = { ( ) => import ( './lsn-content.js' ) }
33
+ stickyData = { stickyData }
18
34
PutAway = { PutAway }
19
35
/>
20
36
) ;
You can’t perform that action at this time.
0 commit comments