File tree Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @openstax/os-webview" ,
3- "version" : " 2.146.0 " ,
3+ "version" : " 2.146.1 " ,
44 "description" : " OpenStax webview" ,
55 "scripts" : {
66 "test" : " jest --coverage ./test/src" ,
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import RawHTML from '~/components/jsx-helpers/raw-html' ;
3- import { usePutAway } from '../../shared' ;
3+ import { usePutAway , StickyDataWithBanner } from '../../shared' ;
44import './sticky-note.scss' ;
55
6- export type StickyNoteProps = {
7- stickyData : {
8- mode : 'emergency' ;
9- emergency_content : string ;
10- } | object | null ;
11- } ;
12-
13- export default function StickyNote ( { stickyData} : StickyNoteProps ) {
6+ export default function StickyNote ( { stickyData} : { stickyData : StickyDataWithBanner | null } ) {
147 const [ closed , PutAway ] = usePutAway ( ) ;
158
16- if ( ! stickyData || closed || ! ( 'emergency_content' in stickyData ) ) {
9+ if ( ! stickyData || closed || stickyData . mode !== 'emergency' ) {
1710 return null ;
1811 }
1912
Original file line number Diff line number Diff line change @@ -15,11 +15,12 @@ type BannerInfo = {
1515type StickyDataRaw = {
1616 start : string ;
1717 expires : string ;
18- emergency_expires : string ;
18+ emergency_expires : string | null ;
19+ emergency_content : string ;
1920 show_popup : boolean ;
2021} ;
2122
22- type StickyDataWithBanner = StickyDataRaw & {
23+ export type StickyDataWithBanner = StickyDataRaw & {
2324 bannerInfo : BannerInfo ;
2425 mode : 'emergency' | 'popup' | 'banner' | null ;
2526} ;
@@ -62,7 +63,7 @@ function getMode(stickyData: StickyDataRaw | null): 'emergency' | 'popup' | 'ban
6263 return null ;
6364 }
6465
65- const expireDate = new Date ( stickyData . emergency_expires ) ;
66+ const expireDate = new Date ( stickyData . emergency_expires ?? 0 ) ;
6667 const useEmergency = stickyData . emergency_expires && Date . now ( ) < expireDate . getTime ( ) ;
6768
6869 if ( useEmergency ) {
You can’t perform that action at this time.
0 commit comments