Skip to content

Commit

Permalink
[FIX] Remove reference to session storage (hedyorg#4331)
Browse files Browse the repository at this point in the history
This code dates from 3 years ago, was a first attempt at code persistence, and isn't very useful anymore. Let's get rid of it.

Fixes hedyorg#4330.

![this is fine](https://i.kym-cdn.com/entries/icons/facebook/000/018/012/this_is_fine.jpg)

**How to test**

Everything works exactly the same (but with less confusion reviewing).
  • Loading branch information
rix0rrr authored Jun 7, 2023
1 parent 6e66aaf commit 4ff3ab2
Showing 1 changed file with 15 additions and 55 deletions.
70 changes: 15 additions & 55 deletions static/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,41 +274,24 @@ function initializeMainEditor($editor: JQuery) {

window.Range = ace.require('ace/range').Range // get reference to ace/range

// Load existing code from session, if it exists
const storage = window.sessionStorage;
if (storage) {
const loadedProgram = $editor.data('loaded-program');

// On page load, if we have a saved program and we are not loading a program by id, we load the saved program
const programFromStorage = storage.getItem(currentTabLsKey());
if (loadedProgram !== 'True' && programFromStorage) {
editor.setValue(programFromStorage?.trim(), MOVE_CURSOR_TO_END);
}

// When the user exits the editor, save what we have.
editor.on('blur', function(_e: Event) {
storage.setItem(currentTabLsKey(), editor.getValue());
});
if (dir === "rtl") {
editor.setOptions({ rtl: true });
}

if (dir === "rtl") {
editor.setOptions({ rtl: true });
// If prompt is shown and user enters text in the editor, hide the prompt.
editor.on('change', function () {
if (askPromptOpen) {
stopit();
editor.focus(); // Make sure the editor has focus, so we can continue typing
}
if ($('#ask-modal').is(':visible')) $('#inline-modal').hide();
askPromptOpen = false;
$ ('#runit').css('background-color', '');

// If prompt is shown and user enters text in the editor, hide the prompt.
editor.on('change', function () {
if (askPromptOpen) {
stopit();
editor.focus(); // Make sure the editor has focus, so we can continue typing
}
if ($('#ask-modal').is(':visible')) $('#inline-modal').hide();
askPromptOpen = false;
$ ('#runit').css('background-color', '');

clearErrors(editor);
//removing the debugging state when loading in the editor
stopDebug();
});
}
clearErrors(editor);
//removing the debugging state when loading in the editor
stopDebug();
});

// *** KEYBOARD SHORTCUTS ***

Expand Down Expand Up @@ -1533,29 +1516,6 @@ function initializeModalEditor($editor: JQuery) {

window.Range = ace.require('ace/range').Range // get reference to ace/range

// Load existing code from session, if it exists
const storage = window.sessionStorage;
if (storage) {
let tempIndex = 0;
let resultString = "";

if(storage.getItem('fixed_{lvl}'.replace("{lvl}", currentTabLsKey()))){
resultString = storage.getItem('fixed_{lvl}'.replace("{lvl}", currentTabLsKey()))?? "";
let tempString = ""
for (let i = 0; i < resultString.length + 1; i++) {
setTimeout(function() {
editor.setValue(tempString,tempIndex);
tempString += resultString[tempIndex];
tempIndex++;
}, 150 * i);
}
}
else{
resultString = storage.getItem('warning_{lvl}'.replace("{lvl}", currentTabLsKey()))?? "";
editor.setValue(resultString);
}
}

// *** KEYBOARD SHORTCUTS ***

let altPressed: boolean | undefined;
Expand Down

0 comments on commit 4ff3ab2

Please sign in to comment.