Skip to content

Commit 856903c

Browse files
authored
feat: show that we've updated our ToS (#8382)
1 parent 2b65879 commit 856903c

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const initializeNewUser = async ({
4242
}
4343

4444
actions.internal.showUserSurveyIfNeeded();
45+
actions.internal.showUpdatedToSIfNeeded();
4546
await effects.live.getSocket();
4647
actions.userNotifications.internal.initialize();
4748
actions.internal.setStoredSettings();
@@ -146,6 +147,41 @@ export const showUserSurveyIfNeeded = ({
146147
}
147148
};
148149

150+
export const showUpdatedToSIfNeeded = ({ state, effects }: Context) => {
151+
const registrationDate = state.user?.insertedAt
152+
? new Date(state.user.insertedAt)
153+
: new Date();
154+
155+
if (registrationDate >= new Date('2024-03-10')) {
156+
// This means that the user has registered before we updated the ToS, and we need to notify
157+
// them that the ToS has changed.
158+
return;
159+
}
160+
161+
const hasShownToS = effects.browser.storage.get('TOS_1_SHOWN');
162+
if (hasShownToS) {
163+
return;
164+
}
165+
166+
effects.browser.storage.set('TOS_1_SHOWN', true);
167+
168+
effects.notificationToast.add({
169+
title: 'Terms of Service Updated',
170+
message: "We've updated our Terms of Service.",
171+
status: NotificationStatus.NOTICE,
172+
sticky: true,
173+
174+
actions: {
175+
primary: {
176+
label: 'Open Terms of Service',
177+
run: () => {
178+
window.open('https://codesandbox.io/legal/terms', '_blank');
179+
},
180+
},
181+
},
182+
});
183+
};
184+
149185
/**
150186
* @deprecated
151187
*/

packages/notifications/src/component/elements.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ export const NotificationContainer = styled.div`
1111

1212
export const StyledCrossIcon = styled(CrossIcon)`
1313
${({ theme }) => css`
14+
position: absolute;
15+
top: 1rem;
16+
right: 1rem;
1417
transition: 0.3s ease color;
1518
cursor: pointer;
16-
color: ${theme.colors.grays[500]};
19+
color: ${theme.colors.grays[400]};
1720
1821
&:hover {
19-
color: ${theme.colors.grays[400]};
22+
color: ${theme.colors.grays[300]};
2023
}
2124
`}
2225
`;

0 commit comments

Comments
 (0)