utils.tsx 466 B

12345678910111213
  1. const WIDGET_LIBRARY_VISITS = 'dashboard-widget-library-visits';
  2. export function shouldShowNewBadge(): boolean {
  3. const visits = localStorage.getItem(WIDGET_LIBRARY_VISITS);
  4. return visits === null || (parseInt(visits, 10) || 0) < 5;
  5. }
  6. export function setWidgetLibraryVisit() {
  7. const visits = localStorage.getItem(WIDGET_LIBRARY_VISITS);
  8. localStorage.setItem(
  9. WIDGET_LIBRARY_VISITS,
  10. visits === null ? '1' : `${(parseInt(visits, 10) || 0) + 1}`
  11. );
  12. }