use SSR constant
This commit is contained in:
parent
49cf1f2e23
commit
4604a7bac9
|
@ -70,13 +70,13 @@ export async function listLocalStorages ({ userId, database }) {
|
|||
*/
|
||||
function createMemBackend (userId, namespace) {
|
||||
const joinedNamespace = userId + ':' + namespace.join(':')
|
||||
let memory = typeof window !== 'undefined' ? window?.snMemStorage?.[joinedNamespace] : null
|
||||
if (!memory) {
|
||||
let memory
|
||||
if (SSR) {
|
||||
memory = {}
|
||||
if (typeof window !== 'undefined') {
|
||||
if (!window.snMemStorage) window.snMemStorage = {}
|
||||
window.snMemStorage[joinedNamespace] = memory
|
||||
}
|
||||
} else {
|
||||
if (!window.snMemStorage) window.snMemStorage = {}
|
||||
memory = window.snMemStorage[joinedNamespace]
|
||||
if (!memory) window.snMemStorage[joinedNamespace] = memory = {}
|
||||
}
|
||||
return {
|
||||
set: (key, value) => { memory[key] = value },
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { useEffect } from 'react'
|
||||
import { SSR } from '@/lib/constants'
|
||||
export * from 'wallets/webln'
|
||||
|
||||
export const sendPayment = async (bolt11) => {
|
||||
if (typeof window.webln === 'undefined') {
|
||||
throw new Error('WebLN provider not found')
|
||||
|
@ -22,7 +22,7 @@ export const sendPayment = async (bolt11) => {
|
|||
}
|
||||
|
||||
export function isAvailable () {
|
||||
return typeof window !== 'undefined' && window?.weblnEnabled
|
||||
return !SSR && window?.weblnEnabled
|
||||
}
|
||||
|
||||
export function WebLnProvider ({ children }) {
|
||||
|
|
Loading…
Reference in New Issue