2023-09-13 11:31:44 +00:00
|
|
|
/** @jsx h */
|
|
|
|
import { h, render } from "https://esm.sh/preact@10.17.1";
|
2023-09-23 21:54:13 +00:00
|
|
|
import { ConversationList } from "./conversation-list.tsx";
|
2023-09-13 11:31:44 +00:00
|
|
|
import { fail } from "https://deno.land/std@0.176.0/testing/asserts.ts";
|
2023-11-16 13:22:18 +00:00
|
|
|
import { Datebase_View } from "../database.ts";
|
2023-09-13 11:31:44 +00:00
|
|
|
import { PrivateKey } from "../lib/nostr-ts/key.ts";
|
2023-12-17 20:41:49 +00:00
|
|
|
import { InMemoryAccountContext, NostrEvent, NostrKind } from "../lib/nostr-ts/nostr.ts";
|
2023-09-23 21:33:30 +00:00
|
|
|
import { testEventBus } from "./_setup.test.ts";
|
2023-09-13 11:31:44 +00:00
|
|
|
import { initialModel } from "./app_model.ts";
|
2023-10-15 22:39:21 +00:00
|
|
|
import { DM_List } from "./conversation-list.ts";
|
2023-09-23 21:33:30 +00:00
|
|
|
import { NewIndexedDB } from "./dexie-db.ts";
|
2023-10-03 18:25:36 +00:00
|
|
|
import { ProfileSyncer } from "../features/profile.ts";
|
2023-11-03 13:09:13 +00:00
|
|
|
import { ConnectionPool } from "../lib/nostr-ts/relay-pool.ts";
|
2023-10-03 18:25:36 +00:00
|
|
|
import { OtherConfig } from "./config-other.ts";
|
2023-11-16 13:22:18 +00:00
|
|
|
import { GroupChatSyncer, GroupMessageController } from "../features/gm.ts";
|
2023-12-17 20:41:49 +00:00
|
|
|
import { Channel } from "https://raw.githubusercontent.com/BlowaterNostr/csp/master/csp.ts";
|
|
|
|
import { LamportTime } from "../time.ts";
|
|
|
|
import { prepareEncryptedNostrEvent } from "../lib/nostr-ts/event.ts";
|
2023-09-13 11:31:44 +00:00
|
|
|
|
2023-12-17 20:41:49 +00:00
|
|
|
const ctx = InMemoryAccountContext.Generate();
|
2023-09-23 21:33:30 +00:00
|
|
|
const db = NewIndexedDB();
|
|
|
|
if (db instanceof Error) {
|
|
|
|
fail(db.message);
|
|
|
|
}
|
2023-11-17 07:06:11 +00:00
|
|
|
const database = await Datebase_View.New(db, db, db);
|
2023-09-13 14:52:01 +00:00
|
|
|
|
2023-11-16 13:22:18 +00:00
|
|
|
const pool = new ConnectionPool();
|
|
|
|
const profileSyncer = new ProfileSyncer(database, pool);
|
2023-09-13 14:52:01 +00:00
|
|
|
|
2023-12-17 20:41:49 +00:00
|
|
|
const gmc = new GroupMessageController(ctx, new GroupChatSyncer(database, pool), profileSyncer);
|
|
|
|
const dm_list = new DM_List(ctx);
|
|
|
|
const event = await prepareEncryptedNostrEvent(ctx, {
|
|
|
|
content: "",
|
|
|
|
encryptKey: ctx.publicKey,
|
|
|
|
kind: NostrKind.DIRECT_MESSAGE,
|
|
|
|
tags: [
|
|
|
|
["p", ctx.publicKey.hex],
|
|
|
|
],
|
|
|
|
}) as NostrEvent;
|
|
|
|
const err = dm_list.addEvents([event]);
|
|
|
|
if (err instanceof Error) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
const otherConfig = OtherConfig.Empty(new Channel(), ctx, new LamportTime());
|
2023-09-13 11:31:44 +00:00
|
|
|
|
2023-09-23 21:33:30 +00:00
|
|
|
const view = () =>
|
|
|
|
render(
|
|
|
|
<ConversationList
|
|
|
|
hasNewMessages={new Set()}
|
2023-10-07 20:40:18 +00:00
|
|
|
eventBus={testEventBus}
|
2023-09-23 21:33:30 +00:00
|
|
|
emit={testEventBus.emit}
|
2023-10-08 00:53:54 +00:00
|
|
|
profileGetter={database}
|
2023-11-16 13:22:18 +00:00
|
|
|
groupChatListGetter={gmc}
|
2023-12-17 20:41:49 +00:00
|
|
|
convoListRetriever={dm_list}
|
|
|
|
pinListGetter={otherConfig}
|
2023-09-23 21:33:30 +00:00
|
|
|
/>,
|
|
|
|
document.body,
|
|
|
|
);
|
2023-09-13 11:31:44 +00:00
|
|
|
|
2023-09-23 21:33:30 +00:00
|
|
|
view();
|