Skip to content

Commit

Permalink
RG-2476 drop StorageFallback component (#7690)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-skl authored Sep 4, 2024
1 parent 7915b18 commit 13cb4ab
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 269 deletions.
6 changes: 1 addition & 5 deletions src/auth/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ export default class AuthStorage<M = unknown> {
this._lastMessage = null;

const StorageConstructor = config.storage || Storage;
this.stateQuota = Math.min(
config.stateQuota ||
DEFAULT_STATE_QUOTA,
StorageConstructor.QUOTA || Infinity
);
this.stateQuota = config.stateQuota || DEFAULT_STATE_QUOTA;

this._stateStorage = new StorageConstructor({
cookieName: 'ring-state'
Expand Down
27 changes: 0 additions & 27 deletions src/storage/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import mockedWindow from 'storage-mock';

import {StorageInterface} from './storage';
import LocalStorage from './storage__local';
import FallbackStorage from './storage__fallback';

function noop() {}

Expand Down Expand Up @@ -233,30 +232,4 @@ describe('Storage', () => {
});
});
});

describe('Fallback', () => {
const cookieName = 'testCookie';

beforeEach(() => {
document.cookie = `${cookieName}=;`;
});

const storage = new FallbackStorage({
cookieName,
checkDelay: 200
});

const storageSession = new FallbackStorage({
cookieName,
checkDelay: 200,
type: 'session'
});
describe('Long-term', () => {
testStorage(storage);
});
describe('Session', () => {
testStorage(storageSession);
});
testStorageEvents(storage);
});
});
25 changes: 1 addition & 24 deletions src/storage/storage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import LocalStorage from './storage__local';
import FallbackStorage from './storage__fallback';

export interface StorageConfig {
type?: 'local' | 'session' | null | undefined
Expand All @@ -17,28 +16,6 @@ export interface StorageInterface {

export interface StorageClass {
new (config?: StorageConfig | undefined): StorageInterface
QUOTA?: number
}

/**
* @name Storage
*/

/**
* @constructor
* @extends {LocalStorage}
*/
let Storage: StorageClass = LocalStorage;

// Using try/catch here because of IE10+ protected mode and other browsers' quirks
// See https://github.com/Modernizr/Modernizr/blob/master/feature-detects/storage/localstorage.js
try {
const temp = 'testStorage';
localStorage.setItem(temp, temp);
localStorage.removeItem(temp);
} catch (e) {
Storage = FallbackStorage;
}

const ActualStorage = Storage;
export default ActualStorage;
export default LocalStorage;
213 changes: 0 additions & 213 deletions src/storage/storage__fallback.ts

This file was deleted.

0 comments on commit 13cb4ab

Please sign in to comment.