Skip the web page close confirmation when crashed or in debug mode

This commit is contained in:
Keavon Chambers
2021-12-21 18:43:02 -08:00
parent 3b7a5548ae
commit 8f100b4f0a
2 changed files with 17 additions and 2 deletions
+11 -2
View File
@@ -44,8 +44,8 @@ impl JsEditorHandle {
// Sends a message to the dispatcher in the Editor Backend
fn dispatch<T: Into<Message>>(&self, message: T) {
// Process no further messages after a crash to avoid spamming the console
let has_crashed = EDITOR_HAS_CRASHED.with(|crash_state| crash_state.borrow().clone());
if let Some(message) = has_crashed {
let possible_crash_message = EDITOR_HAS_CRASHED.with(|crash_state| crash_state.borrow().clone());
if let Some(message) = possible_crash_message {
if !self.instance_received_crashed.get() {
self.handle_response(message);
self.instance_received_crashed.set(true);
@@ -82,6 +82,15 @@ impl JsEditorHandle {
}
}
// ========================================================================
// Create JS -> Rust wrapper functions below
// ========================================================================
pub fn has_crashed(&self) -> JsValue {
let has_crashed = EDITOR_HAS_CRASHED.with(|crash_state| crash_state.borrow().is_some());
has_crashed.into()
}
/// Modify the currently selected tool in the document state store
pub fn select_tool(&self, tool: String) -> Result<(), JsValue> {
match translate_tool_type(&tool) {