Skip to content

Commit

Permalink
adds only id of mode in localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
joaovictor3g committed Apr 30, 2024
1 parent a349087 commit e5469ef
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions web/assets/js/components/modals/playground-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async function handleModeClick(event, mode, element) {

element.classList.add("active");
await renderUIChangesByMode(mode);
localStorage.setItem(localStorageModeKey, JSON.stringify(mode));
localStorage.setItem(localStorageModeKey, value);
hideAccordions();
output.value = "";
deleteContentUrlParam();
Expand All @@ -145,7 +145,7 @@ function renderModeOptions() {
const input = createInputElement(mode);
input.onclick = (e) => handleModeClick(e, mode, divOption);

const { id: modeId } = getCurrentMode();
const modeId = getCurrentMode();

if (urlParams.has("content")) {
const obj = getDecompressedContent(urlParams.get("content"));
Expand Down
2 changes: 1 addition & 1 deletion web/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function run() {
setCost("");

try {
const { id: modeId } = getCurrentMode();
const modeId = getCurrentMode();
const result = eval(modeId, values);
const { output: resultOutput, isError } = result;
if (isError) {
Expand Down
4 changes: 2 additions & 2 deletions web/assets/js/share.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ shareButton.addEventListener("click", share);
function share() {
const values = getRunValues();

const { id: modeId } = getCurrentMode();
const modeId = getCurrentMode();

const str = JSON.stringify({
...values,
Expand All @@ -37,7 +37,7 @@ export const renderSharedContent = (
object,
legacyObjectShared = false
) => {
localStorage.setItem(localStorageModeKey, JSON.stringify(mode));
localStorage.setItem(localStorageModeKey, mode.id);
try {
if (legacyObjectShared) {
new AceEditor("cel").setValue(object.expression, -1);
Expand Down
2 changes: 1 addition & 1 deletion web/assets/js/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ toggleBtn.addEventListener("click", function () {
});

export function applyThemeToEditors(modeParam) {
const { id: modeId } = getCurrentMode();
const modeId = getCurrentMode();
const exprEditor = new AceEditor(modeParam?.id ?? modeId);
setEditorTheme(exprEditor);

Expand Down
4 changes: 2 additions & 2 deletions web/assets/js/utils/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { setEditorTheme } from "../theme.js";
import { getCurrentMode } from "./localStorage.js";

export function getExprEditorValue() {
const { id: modeId } = getCurrentMode();
const modeId = getCurrentMode();
const exprEditor = new AceEditor(modeId);
const exprEditorValue = exprEditor.getValue();
setEditorTheme(exprEditor);
Expand All @@ -39,7 +39,7 @@ export function getInputEditorValue() {
}

export function getRunValues() {
const { id: modeId } = getCurrentMode();
const modeId = getCurrentMode();
const exprEditor = new AceEditor(modeId);
setEditorTheme(exprEditor);
let values = {
Expand Down
2 changes: 1 addition & 1 deletion web/assets/js/utils/localStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export function getCurrentTheme() {
}

export function getCurrentMode() {
return JSON.parse(localStorage.getItem(localStorageModeKey) ?? "{}");
return localStorage.getItem(localStorageModeKey) ?? "cel";
}
2 changes: 1 addition & 1 deletion web/assets/js/utils/render-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function renderExamplesInSelectInstance(mode, examples) {
(example) => example.name === event.target.value
);
if (event.target.value === "Blank") {
const { id: modeId } = getCurrentMode();
const modeId = getCurrentMode();
const exprEditor = new AceEditor(modeId);
exprEditor.setValue("", -1);
setEditorTheme(exprEditor);
Expand Down

0 comments on commit e5469ef

Please sign in to comment.