Write out a root.json file w/ the last overall refresh date (useful for threads with no comments to still show the "Last Refreshed")

This commit is contained in:
Garrett Mills 2025-01-05 17:00:10 -05:00
parent 0460771d5d
commit 834c23735d
2 changed files with 18 additions and 1 deletions

View File

@ -1,6 +1,6 @@
import {getMailboxesToSearch, MailboxIterable} from "../mail/read.ts"; import {getMailboxesToSearch, MailboxIterable} from "../mail/read.ts";
import {withClient} from "../mail/client.ts"; import {withClient} from "../mail/client.ts";
import type {Message, ThreadData} from "../types.ts"; import type {Message, RootData, ThreadData} from "../types.ts";
import {AsyncCollection} from "../bones/collection/AsyncCollection.ts"; import {AsyncCollection} from "../bones/collection/AsyncCollection.ts";
import {sha256} from "../bones/crypto.ts"; import {sha256} from "../bones/crypto.ts";
import {config} from "../config.ts"; import {config} from "../config.ts";
@ -68,5 +68,16 @@ export async function refreshThreadsEntirely(): Promise<void> {
(_, v) => typeof v === 'bigint' ? `${v}` : v) (_, v) => typeof v === 'bigint' ? `${v}` : v)
await Bun.write(`${config.dirs.data}/threads/${threadId}.json`, json) await Bun.write(`${config.dirs.data}/threads/${threadId}.json`, json)
} }
const root: RootData = {
refresh: {
date: now,
},
}
await Bun.write(
`${config.dirs.data}/root.json`,
JSON.stringify(root),
)
}) })
} }

View File

@ -66,3 +66,9 @@ export type ThreadData = {
}, },
comments: ThreadComment[], comments: ThreadComment[],
} }
export type RootData = {
refresh?: {
date: Date,
},
}