Add space membership management

This commit is contained in:
Jon Staab
2025-11-13 13:25:34 -08:00
parent 997b223e95
commit d949d58076
16 changed files with 477 additions and 109 deletions
+2 -2
View File
@@ -16,7 +16,7 @@
cx(
"bg-alt text-base-content overflow-auto text-base-content shadow-md",
"px-4 py-6 bottom-0 left-0 right-0 top-20 rounded-t-box absolute",
"sm:p-6 sm:max-h-[90vh] sm:w-[520px] sm:rounded-box sm:relative sm:top-0",
"sm:p-6 sm:max-h-[90vh] sm:w-[520px] sm:rounded-box sm:relative sm:top-0 sm:relative",
),
)
</script>
@@ -28,7 +28,7 @@
transition:fade={{duration: 300}}
onclick={onClose}>
</button>
<div class="scroll-container relative {extraClass}" transition:fly={{duration: 300}}>
<div class="scroll-container {extraClass}" transition:fly={{duration: 300}}>
{@render children?.()}
</div>
</div>
+7 -20
View File
@@ -27,15 +27,14 @@ export type IDBOptions = {
export class IDB {
idbp: Maybe<Promise<IDBPDatabase>>
ready: Maybe<Promise<void>>
unsubscribers: Maybe<Unsubscriber[]>
status = IDBStatus.Initial
constructor(readonly options: IDBOptions) {}
init(adapters: IDBAdapters) {
if (this.status !== IDBStatus.Initial) {
throw new Error(`Database re-initialized while ${this.status}`)
async init(adapters: IDBAdapters) {
if (this.idbp) {
await this.close()
}
this.status = IDBStatus.Opening
@@ -62,7 +61,7 @@ export class IDB {
blocking() {},
})
this.ready = this.idbp.then(async idbp => {
return this.idbp.then(async idbp => {
window.addEventListener("beforeunload", () => idbp.close())
this.unsubscribers = await Promise.all(adapters.map(({name, init}) => init(this.table(name))))
@@ -132,13 +131,9 @@ export class IDB {
await idbp.close()
// Allow the caller to call reset and re-init immediately
if (this.status === IDBStatus.Closing) {
this.idbp = undefined
this.ready = undefined
this.unsubscribers = undefined
this.status = IDBStatus.Closed
}
this.idbp = undefined
this.unsubscribers = undefined
this.status = IDBStatus.Closed
})
clear = async () => {
@@ -147,14 +142,6 @@ export class IDB {
blocked() {},
})
}
reset = () => {
if (![IDBStatus.Closing, IDBStatus.Closed].includes(this.status)) {
throw new Error("Database reset when not closed")
}
this.status = IDBStatus.Initial
}
}
export class IDBTable<T> {