mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Use local storage to remember the panel state
This is mirroring from scratchr2
This commit is contained in:
parent
d243b5dad7
commit
0f823531b6
1 changed files with 11 additions and 0 deletions
|
@ -32,6 +32,8 @@ const frameless = require('../../lib/frameless');
|
|||
const GUI = require('scratch-gui');
|
||||
const IntlGUI = injectIntl(GUI.default);
|
||||
|
||||
const localStorageAvailable = 'localStorage' in window && window.localStorage !== null;
|
||||
|
||||
class Preview extends React.Component {
|
||||
constructor (props) {
|
||||
super(props);
|
||||
|
@ -80,9 +82,12 @@ class Preview extends React.Component {
|
|||
const singleCommentId = window.location.hash.indexOf(commentHashPrefix) !== -1 &&
|
||||
parseInt(window.location.hash.replace(commentHashPrefix, ''), 10);
|
||||
|
||||
const adminPanelOpen = localStorageAvailable && localStorage.getItem('adminPanelToggled_projects') === 'open';
|
||||
|
||||
this.state = {
|
||||
addToStudioOpen: false,
|
||||
adminModalOpen: false,
|
||||
adminPanelOpen: adminPanelOpen || false,
|
||||
extensions: [],
|
||||
favoriteCount: 0,
|
||||
justShared: false,
|
||||
|
@ -267,9 +272,15 @@ class Preview extends React.Component {
|
|||
}
|
||||
handleCloseAdminPanel () {
|
||||
this.setState({adminPanelOpen: false});
|
||||
if (localStorageAvailable) {
|
||||
localStorage.setItem('adminPanelToggled_projects', 'closed');
|
||||
}
|
||||
}
|
||||
handleOpenAdminPanel () {
|
||||
this.setState({adminPanelOpen: true});
|
||||
if (localStorageAvailable) {
|
||||
localStorage.setItem('adminPanelToggled_projects', 'open');
|
||||
}
|
||||
}
|
||||
handleMessage (messageEvent) {
|
||||
if (messageEvent.data === 'showDialog') {
|
||||
|
|
Loading…
Reference in a new issue