fix: broken sessionstorage
This commit is contained in:
1 parent
d7a4c0e29e
commit
7b5f575aff
2 files changed
+5
-1
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { browser } from '$app/environment'
|
||||
import type { Community } from 'lemmy-js-client'
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
@@ -20,6 +21,7 @@ export const setSessionStorage = (
|
||||
key: keyof SessionStorage,
|
||||
value: SessionStorage[typeof key]
|
||||
) => {
|
||||
if (!browser) return
|
||||
if (value == undefined) {
|
||||
sessionStorage.removeItem(key)
|
||||
} else {
|
||||
@@ -30,6 +32,7 @@ export const setSessionStorage = (
|
||||
export const getSessionStorage = (
|
||||
key: keyof SessionStorage
|
||||
): SessionStorage[typeof key] => {
|
||||
if (!browser) return
|
||||
return JSON.parse(sessionStorage.getItem(key)!)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import { profile } from '$lib/auth.js'
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||
import { t } from '$lib/translations.js'
|
||||
|
||||
export let data = {
|
||||
crosspost: false,
|
||||
@@ -27,7 +28,7 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Create post</title>
|
||||
<title>{$t('form.post.create')}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div class="w-full max-w-5xl mx-auto h-full">
|
||||
|
||||
Reference in new issue
Block a user