forked from mystiq/hydrogen-web
Merge branch 'snowpack-ts-storage-1' into snowpack-ts-storage-2
This commit is contained in:
commit
e610087a79
2 changed files with 23 additions and 30 deletions
|
@ -14,31 +14,28 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const STORE_NAMES: Readonly<string[]> = Object.freeze([
|
export enum StoreNames {
|
||||||
"session",
|
session = "session",
|
||||||
"roomState",
|
roomState = "roomState",
|
||||||
"roomSummary",
|
roomSummary = "roomSummary",
|
||||||
"archivedRoomSummary",
|
archivedRoomSummary = "archivedRoomSummary",
|
||||||
"invites",
|
invites = "invites",
|
||||||
"roomMembers",
|
roomMembers = "roomMembers",
|
||||||
"timelineEvents",
|
timelineEvents = "timelineEvents",
|
||||||
"timelineRelations",
|
timelineRelations = "timelineRelations",
|
||||||
"timelineFragments",
|
timelineFragments = "timelineFragments",
|
||||||
"pendingEvents",
|
pendingEvents = "pendingEvents",
|
||||||
"userIdentities",
|
userIdentities = "userIdentities",
|
||||||
"deviceIdentities",
|
deviceIdentities = "deviceIdentities",
|
||||||
"olmSessions",
|
olmSessions = "olmSessions",
|
||||||
"inboundGroupSessions",
|
inboundGroupSessions = "inboundGroupSessions",
|
||||||
"outboundGroupSessions",
|
outboundGroupSessions = "outboundGroupSessions",
|
||||||
"groupSessionDecryptions",
|
groupSessionDecryptions = "groupSessionDecryptions",
|
||||||
"operations",
|
operations = "operations",
|
||||||
"accountData",
|
accountData = "accountData",
|
||||||
]);
|
}
|
||||||
|
|
||||||
export const STORE_MAP: Readonly<{ [name : string]: string }> = Object.freeze(STORE_NAMES.reduce((nameMap, name) => {
|
export const STORE_NAMES: Readonly<StoreNames[]> = Object.values(StoreNames);
|
||||||
nameMap[name] = name;
|
|
||||||
return nameMap;
|
|
||||||
}, {}));
|
|
||||||
|
|
||||||
export class StorageError extends Error {
|
export class StorageError extends Error {
|
||||||
errcode?: string;
|
errcode?: string;
|
||||||
|
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {Transaction} from "./Transaction.js";
|
import {Transaction} from "./Transaction.js";
|
||||||
import { STORE_NAMES, StorageError } from "../common";
|
import { STORE_NAMES, StoreNames, StorageError } from "../common";
|
||||||
import { reqAsPromise } from "./utils";
|
import { reqAsPromise } from "./utils";
|
||||||
|
|
||||||
const WEBKITEARLYCLOSETXNBUG_BOGUS_KEY = "782rh281re38-boguskey";
|
const WEBKITEARLYCLOSETXNBUG_BOGUS_KEY = "782rh281re38-boguskey";
|
||||||
|
@ -25,11 +25,7 @@ export class Storage {
|
||||||
this._db = idbDatabase;
|
this._db = idbDatabase;
|
||||||
this._IDBKeyRange = IDBKeyRange;
|
this._IDBKeyRange = IDBKeyRange;
|
||||||
this._hasWebkitEarlyCloseTxnBug = hasWebkitEarlyCloseTxnBug;
|
this._hasWebkitEarlyCloseTxnBug = hasWebkitEarlyCloseTxnBug;
|
||||||
const nameMap = STORE_NAMES.reduce((nameMap, name) => {
|
this.storeNames = StoreNames;
|
||||||
nameMap[name] = name;
|
|
||||||
return nameMap;
|
|
||||||
}, {});
|
|
||||||
this.storeNames = Object.freeze(nameMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_validateStoreNames(storeNames) {
|
_validateStoreNames(storeNames) {
|
||||||
|
|
Loading…
Reference in a new issue