Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
run: () => {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
document.documentElement.requestFullscreen();
this.addNotification({
title: 'Fullscreen',
message:
'You are now in fullscreen mode. Press and hold ESC to exit',
status: NotificationStatus.NOTICE,
timeAlive: 5000,
});
if ('keyboard' in navigator) {
// @ts-ignore - keyboard locking is experimental api
navigator.keyboard.lock([
'Escape',
'KeyW',
'KeyN',
'KeyT',
'ArrowLeft',
'ArrowRight',
]);
}
}
},
// TODO: What happening here? Is it not an array of users?
// Check the running code and fix the type
state.live.roomInfo.users = users as any;
state.live.roomInfo.editorIds = data.editor_ids;
state.live.roomInfo.ownerIds = data.owner_ids;
if (data.joined_user_id === state.live.liveUserId) {
return;
}
const user = data.users.find(u => u.id === data.joined_user_id);
if (!state.live.notificationsHidden) {
effects.notificationToast.add({
message: `${user.username} joined the live session.`,
status: NotificationStatus.NOTICE,
});
}
});
notice(message: string) {
notificationState.addNotification({
message,
status: NotificationStatus.NOTICE,
});
},
};
);
const addedPorts = newPorts.filter(
port => !currentPorts.find(p => p.port === port.port)
);
const openedPorts = [];
if (removedPorts.length > 0) {
effects.notificationToast.add({
title: `Server Ports Closed`,
message:
removedPorts.length === 1
? `Port ${removedPorts[0].port} closed`
: `The following ports closed: ${removedPorts
.map(p => p.port)
.join(', ')}`,
status: NotificationStatus.NOTICE,
});
}
editor.devToolTabs.forEach(view => {
view.views.forEach(tab => {
if (
tab.id === 'codesandbox.browser' &&
tab.options &&
tab.options.port
) {
openedPorts.push(tab.options.port);
}
});
});
addedPorts.forEach(port => {
const getStatus = () => {
switch (type) {
case 'error':
return NotificationStatus.ERROR;
case 'warning':
return NotificationStatus.WARNING;
case 'success':
return NotificationStatus.SUCCESS;
default:
return NotificationStatus.NOTICE;
}
};
return false;
})
.filter(Boolean);
const numRecoveredFiles = recoveredList.length;
if (numRecoveredFiles > 0) {
effects.analytics.track('Files Recovered', {
fileCount: numRecoveredFiles,
});
effects.notificationToast.add({
message: `We recovered ${numRecoveredFiles} unsaved ${
numRecoveredFiles > 1 ? 'files' : 'file'
} from a previous session`,
status: NotificationStatus.NOTICE,
});
}
};