Skip to content

Commit 0be1519

Browse files
committed
Fix notifications
1 parent b9ec1f1 commit 0be1519

File tree

1 file changed

+28
-3
lines changed
  • packages/app/src/app/overmind/effects/vscode

1 file changed

+28
-3
lines changed

packages/app/src/app/overmind/effects/vscode/index.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import {
1010
Settings,
1111
} from '@codesandbox/common/lib/types';
1212
import { notificationState } from '@codesandbox/common/lib/utils/notifications';
13-
import { NotificationMessage } from '@codesandbox/notifications/lib/state';
13+
import {
14+
NotificationMessage,
15+
NotificationStatus,
16+
} from '@codesandbox/notifications/lib/state';
1417
import { Reaction } from 'app/overmind';
1518
import prettify from 'app/src/app/utils/prettify';
1619
import { blocker } from 'app/utils/blocker';
@@ -845,8 +848,30 @@ export class VSCodeEffect {
845848
};
846849

847850
// This is used by the CodesandboxService internally
848-
private addNotification(notification: NotificationMessage) {
849-
notificationState.addNotification(notification);
851+
private addNotification(
852+
message: string,
853+
type: 'error' | 'info' | 'warning' | 'success',
854+
options: { actions: NotificationMessage['actions']; sticky?: boolean }
855+
) {
856+
const getStatus = () => {
857+
switch (type) {
858+
case 'error':
859+
return NotificationStatus.ERROR;
860+
case 'warning':
861+
return NotificationStatus.WARNING;
862+
case 'success':
863+
return NotificationStatus.SUCCESS;
864+
default:
865+
return NotificationStatus.NOTICE;
866+
}
867+
};
868+
869+
notificationState.addNotification({
870+
message,
871+
status: getStatus(),
872+
sticky: options.sticky,
873+
actions: options.actions,
874+
});
850875
}
851876
}
852877

0 commit comments

Comments
 (0)