1 // This module manages the logic for showing a spotlight on the public page on the "Open in Drive" button.
2 // The spotlight is designed to be shown only once to each user after they just "Saved" a public share in their Drive.
3 // It uses localStorage to track the spotlight's status across sessions.
5 // - "pending": Waiting for the spotlight to be showed
6 // - "shown": Spotlight has been shown for this user
8 export const PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY = 'public-share-redirect-spotlight';
9 enum PublicShareRedirectSpotlightStatus {
13 export const setPublicRedirectSpotlightToPending = () => {
15 localStorage.setItem(PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY, PublicShareRedirectSpotlightStatus.Pending);
17 console.warn(`localStorage was not available to set key ${PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY}`);
21 export const setPublicRedirectSpotlightToShown = () => {
23 localStorage.setItem(PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY, PublicShareRedirectSpotlightStatus.Shown);
25 console.warn(`localStorage was not available to set key ${PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY}`);
29 export const needPublicRedirectSpotlight = () => {
31 return localStorage.getItem(PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY) === PublicShareRedirectSpotlightStatus.Pending;
33 console.warn(`localStorage was not available to get key ${PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY}`);
38 export const publicRedirectSpotlightWasShown = () => {
40 return localStorage.getItem(PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY) === PublicShareRedirectSpotlightStatus.Shown;
42 console.warn(`localStorage was not available to get key ${PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY}`);