i18n: Upgrade translations from crowdin (a80a6511). (vpn-settings)
[ProtonMail-WebClient.git] / packages / drive-store / utils / publicRedirectSpotlight.ts
blob8d9af57171180513953a56ab741097723c1b1c7a
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.
4 // Status:
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 export enum PublicShareRedirectSpotlightStatus {
10     Pending = 'pending',
11     Shown = 'shown',
13 export const setPublicRedirectSpotlightToPending = () => {
14     try {
15         localStorage.setItem(PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY, PublicShareRedirectSpotlightStatus.Pending);
16     } catch (e) {
17         console.warn(`localStorage was not available to set key ${PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY}`);
18     }
21 export const setPublicRedirectSpotlightToShown = () => {
22     try {
23         localStorage.setItem(PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY, PublicShareRedirectSpotlightStatus.Shown);
24     } catch (e) {
25         console.warn(`localStorage was not available to set key ${PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY}`);
26     }
29 export const needPublicRedirectSpotlight = () => {
30     try {
31         return localStorage.getItem(PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY) === PublicShareRedirectSpotlightStatus.Pending;
32     } catch (e) {
33         console.warn(`localStorage was not available to get key ${PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY}`);
34         return false;
35     }
38 export const publicRedirectSpotlightWasShown = () => {
39     try {
40         return localStorage.getItem(PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY) === PublicShareRedirectSpotlightStatus.Shown;
41     } catch (e) {
42         console.warn(`localStorage was not available to get key ${PUBLIC_SHARE_REDIRECT_SPOTLIGHT_KEY}`);
43         return false;
44     }