Skip to content

Commit 6d52cb9

Browse files
committed
hide hidden on reload
1 parent ea562e4 commit 6d52cb9

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

apps/remix-ide/src/app/components/pinned-panel.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const pinnedPanel = {
2020
export class PinnedPanel extends AbstractPanel {
2121
dispatch: React.Dispatch<any> = () => {}
2222
loggedState: Record<string, any>
23+
pinnedPanelState: Record<string, any> // pluginProfile, isClosed
2324
highlightStamp: number
2425
closedPlugin: any
2526

@@ -36,6 +37,9 @@ export class PinnedPanel extends AbstractPanel {
3637
super.remove(name)
3738
}
3839
})
40+
41+
let pinnedPanelState = window.localStorage.getItem('pinnedPanelState')
42+
if (!pinnedPanelState) window.localStorage.setItem('pinnedPanelState', JSON.stringify({}))
3943
}
4044

4145
async pinView (profile, view) {
@@ -51,11 +55,25 @@ export class PinnedPanel extends AbstractPanel {
5155
}
5256
this.loggedState = await this.call('pluginStateLogger', 'getPluginState', profile.name)
5357
this.addView(profile, view)
54-
this.plugins[profile.name].pinned = true
55-
this.plugins[profile.name].active = true
58+
let pinnedPanelState = window.localStorage.getItem('pinnedPanelState')
59+
let isClosed = false
60+
if (pinnedPanelState) {
61+
pinnedPanelState = JSON.parse(pinnedPanelState)
62+
if (pinnedPanelState['isClosed']) {
63+
isClosed = true
64+
await this.closePlugin(profile)
65+
}
66+
else {
67+
this.plugins[profile.name].pinned = true
68+
this.plugins[profile.name].active = true
69+
}
70+
} else {
71+
this.plugins[profile.name].pinned = true
72+
this.plugins[profile.name].active = true
73+
}
5674
this.renderComponent()
57-
this.events.emit('pinnedPlugin', profile)
58-
this.emit('pinnedPlugin', profile)
75+
this.events.emit('pinnedPlugin', profile, isClosed)
76+
this.emit('pinnedPlugin', profile, isClosed)
5977
}
6078

6179
async unPinView (profile) {
@@ -77,6 +95,7 @@ export class PinnedPanel extends AbstractPanel {
7795
const pinnedPanel = document.querySelector('#pinned-panel')
7896
pinnedPanel.classList.add('d-none')
7997
this.closedPlugin = profile
98+
window.localStorage.setItem('pinnedPanelState', JSON.stringify({pluginProfile: profile, isClosed: true}))
8099
this.events.emit('pluginClosed', profile)
81100
this.emit('pluginClosed', profile)
82101
}
@@ -85,6 +104,7 @@ export class PinnedPanel extends AbstractPanel {
85104
const pinnedPanel = document.querySelector('#pinned-panel')
86105
pinnedPanel.classList.remove('d-none')
87106
this.closedPlugin = null
107+
window.localStorage.setItem('pinnedPanelState', JSON.stringify({pluginProfile: profile, isClosed: false}))
88108
this.events.emit('pluginMaximized', profile)
89109
this.emit('pluginMaximized', profile)
90110
}

libs/remix-ui/app/src/lib/remix-app/remix-app.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ const RemixApp = (props: IRemixAppUi) => {
125125
setLocale(nextLocale)
126126
})
127127

128-
props.app.pinnedPanel.events.on('pinnedPlugin', () => {
129-
setHidePinnedPanel(false)
128+
props.app.pinnedPanel.events.on('pinnedPlugin', (profile, isClosed) => {
129+
if (!isClosed) setHidePinnedPanel(false)
130130
})
131131

132132
props.app.pinnedPanel.events.on('unPinnedPlugin', () => {

0 commit comments

Comments
 (0)