cleanup directory structure

This commit is contained in:
Bruno Windels 2019-02-06 22:04:39 +00:00
parent 90300dcdaf
commit 5c7a1f66d6
12 changed files with 20 additions and 15 deletions

View file

9
index.html Normal file
View file

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="module" src="src/main.js"></script>
</head>
<body>
</body>
</html>

View file

@ -1,8 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<script type="module" src="main.js"></script>
</head>
<body>
</body>
</html>

View file

@ -1,6 +1,6 @@
import Network from "./network.js";
import Session from "./session.js";
import createIdbStorage from "./storage/idb/factory.js";
import createIdbStorage from "./storage/idb/create.js";
const HOMESERVER = "http://localhost:8008";
async function getLoginData(username, password) {

View file

@ -1,3 +1,6 @@
import Storage from "./storage.js";
import { openDatabase } from "./utils.js";
export default async function createIdbStorage(databaseName) {
const db = await openDatabase(databaseName, createStores);
return new Storage(db);
@ -5,8 +8,9 @@ export default async function createIdbStorage(databaseName) {
function createStores(db) {
db.createObjectStore("sync"); //sync token
db.createObjectStore("roomSummary", "room_id", {unique: true});
const timeline = db.createObjectStore("roomTimeline", ["room_id", "sort_key"]);
// any way to make keys unique here?
db.createObjectStore("roomSummary", {keyPath: "room_id"});
const timeline = db.createObjectStore("roomTimeline", {keyPath: ["room_id", "sort_key"]});
timeline.createIndex("by_event_id", ["room_id", "event.event_id"], {unique: true});
// how to get the first/last x events for a room?
// we don't want to specify the sort key, but would need an index for the room_id?
@ -14,5 +18,5 @@ function createStores(db) {
// still, you also can't have a PK of [room_id, sort_key] and get the last or first events with just the room_id? the only thing that changes it that the PK will provide an inherent sorting that you inherit in an index that only has room_id as keyPath??? There must be a better way, need to write a prototype test for this.
// SOLUTION: with numeric keys, you can just us a min/max value to get first/last
// db.createObjectStore("members", ["room_id", "state_key"]);
const state = db.createObjectStore("roomState", ["event.room_id", "event.type", "event.state_key"]);
const state = db.createObjectStore("roomState", {keyPath: ["event.room_id", "event.type", "event.state_key"]});
}

View file

@ -1,6 +1,6 @@
import QueryTarget from "./query-target.js";
export default class Index extends QueryTarget {
export default class StoreIndex extends QueryTarget {
constructor(index) {
this._index = index;
}

View file

@ -1,5 +1,5 @@
import QueryTarget from "./query-target.js";
import Index from "./index.js";
import StoreIndex from "./store-index.js";
export default class Store extends QueryTarget {
constructor(store) {
@ -11,6 +11,6 @@ export default class Store extends QueryTarget {
}
index(indexName) {
return new Index(this._store.index(indexName));
return new StoreIndex(this._store.index(indexName));
}
}