Skip to content

Commit bea1e74

Browse files
1 parent 9dce402 commit bea1e74

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

src/__tests__/offline/browser.spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ tape('Browser offline mode', function (assert) {
112112
});
113113

114114
const sdkReadyFromCache = (client) => () => {
115-
assert.equal(factory.settings.storage.type, 'MEMORY', 'In localhost mode, storage must fallback to memory storage');
116-
117115
const clientStatus = client.__getStatus();
118116
assert.equal(clientStatus.isReadyFromCache, true, 'If ready from cache, READY_FROM_CACHE status must be true');
119117
assert.equal(clientStatus.isReady, false, 'READY status must not be set before READY_FROM_CACHE');

src/factory/browser.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { sdkManagerFactory } from '@splitsoftware/splitio-commons/src/sdkManager
88
import { sdkClientMethodCSFactory } from '@splitsoftware/splitio-commons/src/sdkClient/sdkClientMethodCSWithTT';
99
import { impressionObserverCSFactory } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/impressionObserverCS';
1010
import { integrationsManagerFactory } from '@splitsoftware/splitio-commons/src/integrations/browser';
11-
import { __InLocalStorageMockFactory } from '@splitsoftware/splitio-commons/src/utils/settingsValidation/storage/storageCS';
1211
import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory';
1312
import { LOCALHOST_MODE, STORAGE_LOCALSTORAGE } from '@splitsoftware/splitio-commons/src/utils/constants';
1413
import { createUserConsentAPI } from '@splitsoftware/splitio-commons/src/consent/sdkUserConsent';
@@ -20,10 +19,8 @@ const syncManagerOnlineCSFactory = syncManagerOnlineFactory(pollingManagerCSFact
2019

2120
function getStorage(settings) {
2221
return settings.storage.type === STORAGE_LOCALSTORAGE ?
23-
InLocalStorage(settings.storage)
24-
: settings.storage.__originalType === STORAGE_LOCALSTORAGE ?
25-
__InLocalStorageMockFactory
26-
: InMemoryStorageCSFactory;
22+
InLocalStorage(settings.storage) :
23+
InMemoryStorageCSFactory;
2724
}
2825

2926
/**

src/settings/storage/browser.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,29 @@
11
import { isLocalStorageAvailable } from '@splitsoftware/splitio-commons/src/utils/env/isLocalStorageAvailable';
2-
import { LOCALHOST_MODE, STORAGE_MEMORY } from '@splitsoftware/splitio-commons/src/utils/constants';
2+
import { STORAGE_MEMORY } from '@splitsoftware/splitio-commons/src/utils/constants';
33

44
const STORAGE_LOCALSTORAGE = 'LOCALSTORAGE';
55

66
export function validateStorage(settings) {
77
let {
88
log,
9-
mode,
109
storage: {
1110
type,
1211
options = {},
1312
prefix
1413
} = { type: STORAGE_MEMORY },
1514
} = settings;
16-
let __originalType;
17-
18-
const fallbackToMemory = () => {
19-
__originalType = type;
20-
type = STORAGE_MEMORY;
21-
};
22-
23-
// In localhost mode, fallback to Memory storage and track original type to emit SDK_READY_FROM_CACHE if corresponds.
24-
// ATM, other mode settings (e.g., 'consumer') are ignored in client-side API, and so treated as standalone.
25-
if (mode === LOCALHOST_MODE && type === STORAGE_LOCALSTORAGE) {
26-
fallbackToMemory();
27-
}
2815

2916
// If an invalid storage type is provided OR we want to use LOCALSTORAGE and
3017
// it's not available, fallback into MEMORY
3118
if (type !== STORAGE_MEMORY && type !== STORAGE_LOCALSTORAGE ||
3219
type === STORAGE_LOCALSTORAGE && !isLocalStorageAvailable()) {
33-
fallbackToMemory();
20+
type = STORAGE_MEMORY;
3421
log.error('Invalid or unavailable storage. Fallback into MEMORY storage');
3522
}
3623

3724
return {
3825
type,
3926
options,
4027
prefix,
41-
__originalType
4228
};
4329
}

0 commit comments

Comments
 (0)