fix window checks for SSR

This commit is contained in:
Riccardo Balbo 2024-10-14 17:51:46 +02:00 committed by k00b
parent b70dbeb6d6
commit 49cf1f2e23
1 changed files with 2 additions and 2 deletions

View File

@ -70,10 +70,10 @@ export async function listLocalStorages ({ userId, database }) {
*/
function createMemBackend (userId, namespace) {
const joinedNamespace = userId + ':' + namespace.join(':')
let memory = window?.snMemStorage?.[joinedNamespace]
let memory = typeof window !== 'undefined' ? window?.snMemStorage?.[joinedNamespace] : null
if (!memory) {
memory = {}
if (window) {
if (typeof window !== 'undefined') {
if (!window.snMemStorage) window.snMemStorage = {}
window.snMemStorage[joinedNamespace] = memory
}