Skip to content

Commit 80ee713

Browse files
authored
Make spotlight session caching consistent with server (#31)
1 parent 8e7e47d commit 80ee713

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

apps/spotlight/src/features/form-page/store/actions/initialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type Initialize = (
99

1010
export const initialize: Initialize = (ctx, opts) => {
1111
// Get the session ID from local storage so we can use it on page reload.
12-
const sessionId = window.localStorage.getItem('form_session_id') || undefined;
12+
const sessionId = window.localStorage.getItem(`form_session_id_${opts.formId}`) || undefined;
1313
getFormSession(ctx, {
1414
formId: opts.formId,
1515
route: opts.route,

apps/spotlight/src/features/form-page/store/actions/on-submit-form.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const onSubmitForm: OnSubmitForm = async (ctx, opts) => {
3737
sessionId: submission.data.sessionId,
3838
},
3939
});
40-
window.localStorage.setItem('form_session_id', submission.data.sessionId);
40+
window.localStorage.setItem(`form_session_id_${opts.formId}`, submission.data.sessionId);
4141
} else {
4242
console.error(submission.error);
4343
}

packages/server/src/pages/forms/[id].test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ const submitForm = async (
235235
request: new Request(`http://localhost/forms/${formId}`, {
236236
method: 'POST',
237237
body: formData,
238-
headers: sessionId ? { Cookie: `form_session_id=${sessionId}` } : {},
238+
headers: sessionId ? { Cookie: `form_session_id_${formId}=${sessionId}` } : {},
239239
}),
240240
});
241241

0 commit comments

Comments
 (0)