diff --git a/src/lib/cacheStorage.ts b/src/lib/cacheStorage.ts index 8dbad495..c7c6907a 100644 --- a/src/lib/cacheStorage.ts +++ b/src/lib/cacheStorage.ts @@ -1,5 +1,6 @@ import { blobConstruct } from '../helpers/blob'; import FileManager from './filemanager'; +import { Modes } from './mtproto/mtproto_config'; //import { MOUNT_CLASS_TO } from './mtproto/mtproto_config'; //import { logger } from './polyfill'; @@ -10,6 +11,10 @@ export default class CacheStorageController { //private log: ReturnType = logger('CS'); constructor(public dbName: string) { + if(Modes.test) { + this.dbName += '_test'; + } + this.openDatabase(); } diff --git a/src/lib/mtproto/mtproto_config.ts b/src/lib/mtproto/mtproto_config.ts index 12aaa9a7..e10a64ad 100644 --- a/src/lib/mtproto/mtproto_config.ts +++ b/src/lib/mtproto/mtproto_config.ts @@ -12,18 +12,6 @@ export const App = { baseDcId: 2 }; -export type DatabaseStoreName = 'session' | 'stickerSets'; -export type DatabaseStore = Omit & {name: DatabaseStoreName}; -export const Database = { - name: 'tweb', - version: 5, - stores: [{ - name: 'session' - }, { - name: 'stickerSets' - }] as DatabaseStore[], -}; - export const Modes = { test: location.search.indexOf('test=1') > 0/* || true */, debug: location.search.indexOf('debug=1') > 0, @@ -32,5 +20,17 @@ export const Modes = { multipleConnections: true }; -export const DEBUG = process.env.NODE_ENV != 'production'; +export type DatabaseStoreName = 'session' | 'stickerSets'; +export type DatabaseStore = Omit & {name: DatabaseStoreName}; +export const Database = { + name: 'tweb' + (Modes.test ? '_test' : ''), + version: 5, + stores: [{ + name: 'session' + }, { + name: 'stickerSets' + }] as DatabaseStore[], +}; + +export const DEBUG = process.env.NODE_ENV !== 'production' || Modes.debug; export const MOUNT_CLASS_TO: any = DEBUG ? (typeof(window) !== 'undefined' ? window : self) : null;