Fix minor inconsistencies
parent
cf97d04b1b
commit
b47c07da74
|
@ -42,7 +42,7 @@ export function getAttachmentMeta(name: string): Promise<AttachmentMeta> {
|
||||||
*/
|
*/
|
||||||
export function readAttachment(
|
export function readAttachment(
|
||||||
name: string,
|
name: string,
|
||||||
): Promise<{ data: Uint8Array; meta: AttachmentMeta }> {
|
): Promise<Uint8Array> {
|
||||||
return syscall("space.readAttachment", name);
|
return syscall("space.readAttachment", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,9 @@ export async function publishCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function publish(pageName: string, uris: string[]) {
|
async function publish(pageName: string, uris: string[]) {
|
||||||
|
if (!Array.isArray(uris)) {
|
||||||
|
uris = [uris];
|
||||||
|
}
|
||||||
for (const uri of uris) {
|
for (const uri of uris) {
|
||||||
const publisher = uri.split(":")[0];
|
const publisher = uri.split(":")[0];
|
||||||
const results = await events.dispatchEvent(
|
const results = await events.dispatchEvent(
|
||||||
|
|
12
web/space.ts
12
web/space.ts
|
@ -17,9 +17,8 @@ export type SpaceEvents = {
|
||||||
const pageWatchInterval = 5000;
|
const pageWatchInterval = 5000;
|
||||||
|
|
||||||
export class Space extends EventEmitter<SpaceEvents> {
|
export class Space extends EventEmitter<SpaceEvents> {
|
||||||
pageMetaCache = new Map<string, PageMeta>();
|
|
||||||
|
|
||||||
imageHeightCache: Record<string, number> = {};
|
imageHeightCache: Record<string, number> = {};
|
||||||
|
pageMetaCache = new Map<string, PageMeta>();
|
||||||
|
|
||||||
debouncedCacheFlush = throttle(() => {
|
debouncedCacheFlush = throttle(() => {
|
||||||
this.kvStore.set("imageHeightCache", this.imageHeightCache).catch(
|
this.kvStore.set("imageHeightCache", this.imageHeightCache).catch(
|
||||||
|
@ -168,16 +167,21 @@ export class Space extends EventEmitter<SpaceEvents> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We're listing all pages that don't start with a _
|
||||||
|
isListedPageName(name: string): boolean {
|
||||||
|
return name.endsWith(".md") && !name.startsWith("_");
|
||||||
|
}
|
||||||
|
|
||||||
async fetchPageList(): Promise<PageMeta[]> {
|
async fetchPageList(): Promise<PageMeta[]> {
|
||||||
return (await this.spacePrimitives.fetchFileList())
|
return (await this.spacePrimitives.fetchFileList())
|
||||||
.filter((fileMeta) => fileMeta.name.endsWith(".md"))
|
.filter((fileMeta) => this.isListedPageName(fileMeta.name))
|
||||||
.map(fileMetaToPageMeta);
|
.map(fileMetaToPageMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchAttachmentList(): Promise<AttachmentMeta[]> {
|
async fetchAttachmentList(): Promise<AttachmentMeta[]> {
|
||||||
return (await this.spacePrimitives.fetchFileList()).filter(
|
return (await this.spacePrimitives.fetchFileList()).filter(
|
||||||
(fileMeta) =>
|
(fileMeta) =>
|
||||||
!fileMeta.name.endsWith(".md") &&
|
!this.isListedPageName(fileMeta.name) &&
|
||||||
!fileMeta.name.endsWith(".plug.js"),
|
!fileMeta.name.endsWith(".plug.js"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue