diff --git a/packages/app/src/app/overmind/internalActions.ts b/packages/app/src/app/overmind/internalActions.ts
index 819ecd6f495..4faf2ab60aa 100755
--- a/packages/app/src/app/overmind/internalActions.ts
+++ b/packages/app/src/app/overmind/internalActions.ts
@@ -513,7 +513,7 @@ export const handleError: Action<{
});
};
-export const trackCurrentTeams: AsyncAction = async ({ state, effects }) => {
+export const trackCurrentTeams: AsyncAction = async ({ effects }) => {
const { me } = await effects.gql.queries.teams({});
if (me) {
effects.analytics.setGroup(
@@ -526,3 +526,33 @@ export const trackCurrentTeams: AsyncAction = async ({ state, effects }) => {
);
}
};
+
+const seenTermsKey = 'ACCEPTED_TERMS_CODESANDBOX';
+export const showPrivacyPolicyNotification: Action = ({ effects, state }) => {
+ if (effects.browser.storage.get(seenTermsKey)) {
+ return;
+ }
+
+ if (!state.isFirstVisit) {
+ effects.analytics.track('Saw Privacy Policy Notification');
+ effects.notificationToast.add({
+ message:
+ 'Hello, our privacy policy has been updated recently. What’s new? CodeSandbox emails. Please read and reach out.',
+ title: 'Updated Privacy',
+ status: NotificationStatus.NOTICE,
+ sticky: true,
+ actions: {
+ primary: [
+ {
+ label: 'Open Privacy Policy',
+ run: () => {
+ window.open('https://codesandbox.io/legal/privacy', '_blank');
+ },
+ },
+ ],
+ },
+ });
+ }
+
+ effects.browser.storage.set(seenTermsKey, true);
+};
diff --git a/packages/app/src/app/overmind/onInitialize.ts b/packages/app/src/app/overmind/onInitialize.ts
index 72a807ecd07..9fa0eec62ab 100755
--- a/packages/app/src/app/overmind/onInitialize.ts
+++ b/packages/app/src/app/overmind/onInitialize.ts
@@ -1,4 +1,3 @@
-import { NotificationStatus } from '@codesandbox/notifications';
import { OnInitialize } from '.';
export const onInitialize: OnInitialize = async (
@@ -6,7 +5,6 @@ export const onInitialize: OnInitialize = async (
overmindInstance
) => {
const provideJwtToken = () => state.jwt || effects.jwt.get();
- const seenTermsKey = 'ACCEPTED_TERMS_CODESANDBOX';
state.isFirstVisit = Boolean(
!effects.jwt.get() && !effects.browser.storage.get('hasVisited')
@@ -107,26 +105,5 @@ export const onInitialize: OnInitialize = async (
effects.preview.initialize(overmindInstance.reaction);
- // show terms message on first visit since new terms
- if (!effects.browser.storage.get(seenTermsKey) && !state.isFirstVisit) {
- effects.analytics.track('Saw Privacy Policy Notification');
- effects.notificationToast.add({
- message:
- 'Hello, our privacy policy has been updated recently. What’s new? CodeSandbox emails. Please read and reach out.',
- title: 'Updated Privacy',
- status: NotificationStatus.NOTICE,
- sticky: true,
- actions: {
- primary: [
- {
- label: 'Open Privacy Policy',
- run: () => {
- window.open('https://codesandbox.io/legal/privacy', '_blank');
- },
- },
- ],
- },
- });
- }
- effects.browser.storage.set(seenTermsKey, true);
+ actions.internal.showPrivacyPolicyNotification();
};
diff --git a/packages/homepage/src/components/Toast/index.js b/packages/homepage/src/components/Toast/index.js
index 967cfed7805..4b2f58ff969 100644
--- a/packages/homepage/src/components/Toast/index.js
+++ b/packages/homepage/src/components/Toast/index.js
@@ -1,4 +1,3 @@
-/* eslint-disable jsx-a11y/control-has-associated-label */
import React, { useState, useEffect } from 'react';
import track from '@codesandbox/common/lib/utils/analytics';
import { Link } from 'gatsby';
@@ -6,12 +5,12 @@ import { AnimatePresence } from 'framer-motion';
import { ToastContainer } from './elements';
+const key = 'ACCEPTED_TERMS_CODESANDBOX';
const Privacy = () => {
- const key = 'ACCEPTED_TERMS_CODESANDBOX';
const [show, setShow] = useState(false);
useEffect(() => {
- const hasSeen = !!window.localStorage.getItem(key);
+ const hasSeen = Boolean(window.localStorage.getItem(key));
if (!hasSeen) {
setShow(true);
window.localStorage.setItem(key, true);
@@ -33,7 +32,7 @@ const Privacy = () => {
Privacy Policy