@@ -20,6 +20,7 @@ const pinnedPanel = {
2020export 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 }
0 commit comments