Skip to content

Commit 945b02e

Browse files
committed
fix(state): save state
1 parent fa3e706 commit 945b02e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

packages/forms/src/components-control/form-utils/view-state.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default class ViewStateManager {
3030
}
3131

3232
get useState() {
33-
return this.stateProp && this._astro.request.method === 'POST';
33+
return this.stateProp;
3434
}
3535

3636
constructor(private _bind: BindForm<any>, private _elementsState: any, private _astro: AstroGlobal, private _bindId: string | number) {
@@ -70,27 +70,27 @@ export default class ViewStateManager {
7070
}
7171

7272
public async loadState() {
73-
if (!this.useState) {
73+
if (!this.useState || this._astro.request.method !== 'POST') {
7474
return false;
7575
}
7676

7777
const state: any = await this._parseState();
7878
if (!state) return false;
7979

80-
if(state.bind && state.elements){
80+
if (state.bind && state.elements) {
8181
Object.assign(this._bind, state.bind);
8282
Object.assign(this._elementsState, state.elements);
8383
}
8484
return true;
8585
}
8686

8787
public async createViewState(): Promise<string> {
88-
const data = this.useState ?{
88+
const data = this.useState ? {
8989
bind: this.omitProps ?
90-
omitProps(this._bind.__getState(), this.omitProps):
90+
omitProps(this._bind.__getState(), this.omitProps) :
9191
getSomeProps(this._bind.__getState(), this.stateProp),
9292
elements: this._elementsState
93-
}: {};
93+
} : {};
9494

9595
const stringify = superjson.stringify(data);
9696
const compress = await snappy.compress(stringify, {});

0 commit comments

Comments
 (0)