From 834c23735d599acfebbb1da75eae6ff94649bd9b Mon Sep 17 00:00:00 2001 From: garrettmills Date: Sun, 5 Jan 2025 17:00:10 -0500 Subject: [PATCH] Write out a root.json file w/ the last overall refresh date (useful for threads with no comments to still show the "Last Refreshed") --- src/threads/refresh.ts | 13 ++++++++++++- src/types.ts | 6 ++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/threads/refresh.ts b/src/threads/refresh.ts index 86b1d97..6012ece 100644 --- a/src/threads/refresh.ts +++ b/src/threads/refresh.ts @@ -1,6 +1,6 @@ import {getMailboxesToSearch, MailboxIterable} from "../mail/read.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 {sha256} from "../bones/crypto.ts"; import {config} from "../config.ts"; @@ -68,5 +68,16 @@ export async function refreshThreadsEntirely(): Promise { (_, v) => typeof v === 'bigint' ? `${v}` : v) 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), + ) }) } diff --git a/src/types.ts b/src/types.ts index 2b1e1f6..5599797 100644 --- a/src/types.ts +++ b/src/types.ts @@ -66,3 +66,9 @@ export type ThreadData = { }, comments: ThreadComment[], } + +export type RootData = { + refresh?: { + date: Date, + }, +}