ignore: share page stuff

This commit is contained in:
Dax Raad
2025-06-18 16:13:09 -04:00
parent ac777b77cf
commit 658067186a
4 changed files with 21 additions and 11 deletions

View File

@@ -9,10 +9,7 @@
"dev": "bun run ./src/index.ts"
},
"exports": {
"./*": [
"./src/*.ts",
"./src/*/index.ts"
]
"./*": "./src/*.ts"
},
"devDependencies": {
"@tsconfig/bun": "1.0.7",

View File

@@ -42,7 +42,6 @@ export namespace Session {
parentID: Identifier.schema("session").optional(),
share: z
.object({
secret: z.string(),
url: z.string(),
})
.optional(),
@@ -58,6 +57,12 @@ export namespace Session {
})
export type Info = z.output<typeof Info>
export const ShareInfo = z.object({
secret: z.string(),
url: z.string(),
})
export type ShareInfo = z.output<typeof ShareInfo>
export const Event = {
Updated: Bus.event(
"session.updated",
@@ -132,13 +137,20 @@ export namespace Session {
return read as Info
}
export async function getShare(id: string) {
return Storage.readJSON<ShareInfo>("session/share/" + id)
}
export async function share(id: string) {
const session = await get(id)
if (session.share) return session.share
const share = await Share.create(id)
await update(id, (draft) => {
draft.share = share
draft.share = {
url: share.url,
}
})
await Storage.writeJSON<ShareInfo>("session/share/" + id, share)
for (const msg of await messages(id)) {
await Share.sync("session/message/" + id + "/" + msg.id, msg)
}

View File

@@ -19,10 +19,11 @@ export namespace Share {
export async function sync(key: string, content: any) {
const [root, ...splits] = key.split("/")
if (root !== "session") return
const [, sessionID] = splits
const session = await Session.get(sessionID)
if (!session.share) return
const { secret } = session.share
const [sub, sessionID] = splits
if (sub === "share") return
const share = await Session.getShare(sessionID).catch(() => {})
if (!share) return
const { secret } = share
pending.set(key, content)
queue = queue
.then(async () => {

View File

@@ -37,7 +37,7 @@ import CodeBlock from "./CodeBlock"
import MarkdownView from "./MarkdownView"
import styles from "./share.module.css"
import { type Message } from "opencode/session/message"
import { type Session } from "opencode/session"
import { type Session } from "opencode/session/index"
const MIN_DURATION = 2