refactor(state): add ChatData::format_for for the per-site caption format

Four call sites (cache hit, fresh fetch, startup refetch, /debug preview)
spelled out the same message_format.get(...).cloned().unwrap_or_default();
the accessor names the lookup and keeps the empty-format contract in one
place.
This commit is contained in:
2026-09-21 17:27:42 +08:00
parent 26581cfca1
commit dd98a90a45
3 changed files with 12 additions and 19 deletions
+8
View File
@@ -23,6 +23,14 @@ pub struct ChatData {
pub message_format: HashMap<String, String>,
}
impl ChatData {
/// The chat's caption format for `site`, empty when it has none — the
/// built-in caption then applies (`caption_from_fields`).
pub fn format_for(&self, site: &str) -> String {
self.message_format.get(site).cloned().unwrap_or_default()
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct EditMessage {
pub url: String,