Skip to content

Commit

Permalink
add check in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Aug 24, 2024
1 parent c60feda commit 7cd06e5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions frontend/components/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,13 +788,23 @@ all patches: ${JSON.stringify(patches, null, 1)}

this.apply_notebook_patches = apply_notebook_patches
// these are update message that are _not_ a response to a `send(*, *, {create_promise: true})`
this.last_update_counter = -1
const check_update_counter = (new_val) => {
if (new_val <= this.last_update_counter) {
console.error("State update out of order", new_val, this.last_update_counter)
alert("Oopsie!! please refresh your browser and everything will be alright!")
}
this.last_update_counter = new_val
}

const on_update = (update, by_me) => {
if (this.state.notebook.notebook_id === update.notebook_id) {
const show_debugs = launch_params.binder_url != null
if (show_debugs) console.debug("on_update", update, by_me)
const message = update.message
switch (update.type) {
case "notebook_diff":
check_update_counter(message?.counter)
let apply_promise = Promise.resolve()
if (message?.response?.from_reset) {
console.log("Trying to reset state after failure")
Expand Down

0 comments on commit 7cd06e5

Please sign in to comment.