Skip to content

Commit 1a9fb01

Browse files
committed
Let the server know if you've seen the survey question
1 parent 2d29037 commit 1a9fb01

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

packages/app/src/app/store/actions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,11 @@ export function setCurrentModuleShortid({ props, state }) {
179179
}
180180
}
181181

182-
export function showUserSurveyIfNeeded({ state, controller }) {
182+
export function showUserSurveyIfNeeded({ state, controller, api }) {
183183
if (state.get('user.sendSurvey')) {
184+
// Let the server know that we've seen the survey
185+
api.post('/users/survey-seen', {});
186+
184187
notificationState.addNotification({
185188
title: 'Help improve CodeSandbox',
186189
message:

packages/notifications/src/component/Toasts.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,16 @@ export function Toasts({ state }: { state: NotificationState }) {
7171
const removeNotification = React.useCallback((id: string) => {
7272
setNotificationsToShow(notifs => {
7373
const newNotifs = notifs.filter(notif => notif.id !== id);
74+
const notifToHide = notifs.find(notif => notif.id === id);
7475

7576
if (newNotifs.length !== notifs.length) {
7677
return newNotifs;
7778
}
7879

80+
if (notifToHide.notification.onHide) {
81+
notifToHide.notification.onHide();
82+
}
83+
7984
return notifs;
8085
});
8186
}, []);

packages/notifications/src/state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface NotificationMessage {
3232
secondary?: NotificationAction[];
3333
};
3434
timeAlive?: number;
35+
onHide?: () => void;
3536
status: NotificationStatus;
3637
}
3738

0 commit comments

Comments
 (0)