1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-26 00:11:13 +02:00

retain console open state on refreshes. fixes #435

This commit is contained in:
Kushagra Gour
2023-10-13 17:30:15 +05:30
parent f249d34f2f
commit d7c127de70
3 changed files with 13 additions and 6 deletions

View File

@@ -15,6 +15,7 @@ import { Console } from './Console';
import CssSettingsModal from './CssSettingsModal';
import { PreviewDimension } from './PreviewDimension.jsx';
import Modal from './Modal.jsx';
import { LocalStorageKeys } from '../constants.js';
const minCodeWrapSize = 33;
/* global htmlCodeEl
@@ -24,7 +25,9 @@ export default class ContentWrap extends Component {
constructor(props) {
super(props);
this.state = {
isConsoleOpen: false,
isConsoleOpen:
window.localStorage.getItem(LocalStorageKeys.WAS_CONSOLE_OPEN) ===
'true',
isCssSettingsModalOpen: false,
isPreviewNotWorkingModalVisible: false,
logs: []
@@ -574,8 +577,10 @@ export default class ContentWrap extends Component {
}
toggleConsole() {
this.setState({ isConsoleOpen: !this.state.isConsoleOpen });
const newValue = !this.state.isConsoleOpen;
this.setState({ isConsoleOpen: newValue });
trackEvent('ui', 'consoleToggle');
window.localStorage.setItem(LocalStorageKeys.WAS_CONSOLE_OPEN, newValue);
}
consoleHeaderDblClickHandler(e) {
if (!e.target.classList.contains('js-console__header')) {

View File

@@ -68,15 +68,12 @@ import {
import { commandPaletteService } from '../commandPaletteService';
import { I18nProvider } from '@lingui/react';
import { LocalStorageKeys } from '../constants.js';
if (module.hot) {
require('preact/debug');
}
const LocalStorageKeys = {
LOGIN_AND_SAVE_MESSAGE_SEEN: 'loginAndsaveMessageSeen',
ASKED_TO_IMPORT_CREATIONS: 'askedToImportCreations'
};
const UNSAVED_WARNING_COUNT = 15;
const version = '5.0.3';

5
src/constants.js Normal file
View File

@@ -0,0 +1,5 @@
export const LocalStorageKeys = {
LOGIN_AND_SAVE_MESSAGE_SEEN: 'loginAndsaveMessageSeen',
ASKED_TO_IMPORT_CREATIONS: 'askedToImportCreations',
WAS_CONSOLE_OPEN: 'wasConsoleOpen'
};