@@ -30,7 +30,7 @@ export default class ViewStateManager {
30
30
}
31
31
32
32
get useState ( ) {
33
- return this . stateProp && this . _astro . request . method === 'POST' ;
33
+ return this . stateProp ;
34
34
}
35
35
36
36
constructor ( private _bind : BindForm < any > , private _elementsState : any , private _astro : AstroGlobal , private _bindId : string | number ) {
@@ -70,27 +70,27 @@ export default class ViewStateManager {
70
70
}
71
71
72
72
public async loadState ( ) {
73
- if ( ! this . useState ) {
73
+ if ( ! this . useState || this . _astro . request . method !== 'POST' ) {
74
74
return false ;
75
75
}
76
76
77
77
const state : any = await this . _parseState ( ) ;
78
78
if ( ! state ) return false ;
79
79
80
- if ( state . bind && state . elements ) {
80
+ if ( state . bind && state . elements ) {
81
81
Object . assign ( this . _bind , state . bind ) ;
82
82
Object . assign ( this . _elementsState , state . elements ) ;
83
83
}
84
84
return true ;
85
85
}
86
86
87
87
public async createViewState ( ) : Promise < string > {
88
- const data = this . useState ?{
88
+ const data = this . useState ? {
89
89
bind : this . omitProps ?
90
- omitProps ( this . _bind . __getState ( ) , this . omitProps ) :
90
+ omitProps ( this . _bind . __getState ( ) , this . omitProps ) :
91
91
getSomeProps ( this . _bind . __getState ( ) , this . stateProp ) ,
92
92
elements : this . _elementsState
93
- } : { } ;
93
+ } : { } ;
94
94
95
95
const stringify = superjson . stringify ( data ) ;
96
96
const compress = await snappy . compress ( stringify , { } ) ;
0 commit comments