Skip to content

Commit cc21dbf

Browse files
authored
Revert "Switch to localStorage (#1782)" (#1796)
This reverts commit 3d037e8.
1 parent 5091de7 commit cc21dbf

File tree

5 files changed

+22
-30
lines changed

5 files changed

+22
-30
lines changed

.changeset/slow-peaches-vanish.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/fcl/src/fcl.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
export * from "./shared-exports"
1+
export * from './shared-exports';
22

33
import {getMutate} from "./exec/mutate"
44
export const mutate = getMutate({platform: "web"})
55

66
import {getCurrentUser} from "./current-user"
7-
const currentUser = getCurrentUser({platform: "web"})
7+
const currentUser = getCurrentUser({platform:"web"})
88

99
export {currentUser}
1010

@@ -19,8 +19,6 @@ export const logIn = (opts = {}) => currentUser().authenticate(opts)
1919

2020
export const authz = currentUser().authorization
2121

22-
export {LOCAL_STORAGE, SESSION_STORAGE} from "./utils/web"
23-
2422
import {config} from "@onflow/config"
2523
import {getDefaultConfig, coreStrategies} from "./utils/web"
2624
import {initServiceRegistry} from "./current-user/exec-service/plugins"
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
import {LOCAL_STORAGE} from "./storage"
1+
const isServerSide = () => typeof window === "undefined"
2+
3+
const getSessionStorage = () => {
4+
try {
5+
const SESSION_STORAGE = {
6+
can: !isServerSide(),
7+
get: async key => JSON.parse(sessionStorage.getItem(key)),
8+
put: async (key, value) => sessionStorage.setItem(key, JSON.stringify(value)),
9+
}
10+
return SESSION_STORAGE
11+
} catch (error) {
12+
return null
13+
}
14+
}
215

316
export const getDefaultConfig = () => {
417
return {
518
"discovery.wallet.method.default": "IFRAME/RPC",
6-
"fcl.storage.default": LOCAL_STORAGE,
19+
"fcl.storage.default": getSessionStorage(),
720
}
821
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
export {renderFrame} from "./render-frame"
2-
export {renderPop} from "./render-pop"
3-
export {renderTab} from "./render-tab"
4-
export {getDefaultConfig} from "./default-config"
5-
export {coreStrategies} from "./coreStrategies"
6-
export {LOCAL_STORAGE, SESSION_STORAGE} from "./storage"
1+
export {renderFrame} from './render-frame'
2+
export {renderPop} from './render-pop'
3+
export {renderTab} from './render-tab'
4+
export {getDefaultConfig} from './default-config'
5+
export {coreStrategies} from './coreStrategies'

packages/fcl/src/utils/web/storage.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)