Skip to content

Commit dce7cce

Browse files
committed
Extract showPrivacyPolicyNotification action
1 parent 7c2289a commit dce7cce

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

packages/app/src/app/overmind/internalActions.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ export const handleError: Action<{
509509
});
510510
};
511511

512-
export const trackCurrentTeams: AsyncAction = async ({ state, effects }) => {
512+
export const trackCurrentTeams: AsyncAction = async ({ effects }) => {
513513
const { me } = await effects.gql.queries.teams({});
514514
if (me) {
515515
effects.analytics.setGroup(
@@ -522,3 +522,30 @@ export const trackCurrentTeams: AsyncAction = async ({ state, effects }) => {
522522
);
523523
}
524524
};
525+
526+
const seenTermsKey = 'ACCEPTED_TERMS_CODESANDBOX';
527+
export const showPrivacyPolicyNotification: Action = ({ effects, state }) => {
528+
if (effects.browser.storage.get(seenTermsKey) || state.isFirstVisit) {
529+
return;
530+
}
531+
532+
effects.analytics.track('Saw Privacy Policy Notification');
533+
effects.notificationToast.add({
534+
message:
535+
'Hello, our privacy policy has been updated recently. What’s new? CodeSandbox emails. Please read and reach out.',
536+
title: 'Updated Privacy',
537+
status: NotificationStatus.NOTICE,
538+
sticky: true,
539+
actions: {
540+
primary: [
541+
{
542+
label: 'Open Privacy Policy',
543+
run: () => {
544+
window.open('https://codesandbox.io/legal/privacy', '_blank');
545+
},
546+
},
547+
],
548+
},
549+
});
550+
effects.browser.storage.set(seenTermsKey, true);
551+
};

packages/app/src/app/overmind/onInitialize.ts

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import { NotificationStatus } from '@codesandbox/notifications';
21
import { OnInitialize } from '.';
32

43
export const onInitialize: OnInitialize = async (
54
{ state, effects, actions },
65
overmindInstance
76
) => {
87
const provideJwtToken = () => state.jwt || effects.jwt.get();
9-
const seenTermsKey = 'ACCEPTED_TERMS_CODESANDBOX';
108

119
state.isFirstVisit = Boolean(
1210
!effects.jwt.get() && !effects.browser.storage.get('hasVisited')
@@ -107,28 +105,5 @@ export const onInitialize: OnInitialize = async (
107105

108106
effects.preview.initialize(overmindInstance.reaction);
109107

110-
// show terms message on first visit since new terms
111-
if (effects.browser.storage.get(seenTermsKey) || state.isFirstVisit) {
112-
return;
113-
}
114-
115-
effects.analytics.track('Saw Privacy Policy Notification');
116-
effects.notificationToast.add({
117-
message:
118-
'Hello, our privacy policy has been updated recently. What’s new? CodeSandbox emails. Please read and reach out.',
119-
title: 'Updated Privacy',
120-
status: NotificationStatus.NOTICE,
121-
sticky: true,
122-
actions: {
123-
primary: [
124-
{
125-
label: 'Open Privacy Policy',
126-
run: () => {
127-
window.open('https://codesandbox.io/legal/privacy', '_blank');
128-
},
129-
},
130-
],
131-
},
132-
});
133-
effects.browser.storage.set(seenTermsKey, true);
108+
actions.internal.showPrivacyPolicyNotification();
134109
};

0 commit comments

Comments
 (0)