chore(web): rename alias to Doc

now doesn't clash anymore
This commit is contained in:
əlemi 2025-01-19 04:51:06 +01:00
parent 51ce2f5272
commit 4e667e9309
Signed by: alemi
GPG key ID: A4895B84D311642C
8 changed files with 15 additions and 15 deletions
web/src

View file

@ -5,7 +5,7 @@ use apb::{Activity, ActivityMut, Base, Object};
#[component]
pub fn ActivityLine(activity: crate::Object, children: Children) -> impl IntoView {
pub fn ActivityLine(activity: crate::Doc, children: Children) -> impl IntoView {
let object_id = activity.object().id().unwrap_or_default();
let to = activity.to().all_ids();
let cc = activity.cc().all_ids();
@ -46,7 +46,7 @@ pub fn ActivityLine(activity: crate::Object, children: Children) -> impl IntoVie
#[component]
pub fn Item(
item: crate::Object,
item: crate::Doc,
#[prop(optional)] sep: bool,
#[prop(optional)] slim: bool,
#[prop(optional)] always: bool,

View file

@ -23,7 +23,7 @@ impl ReplyControls {
}
}
fn post_author(post_id: &str) -> Option<crate::Object> {
fn post_author(post_id: &str) -> Option<crate::Doc> {
let usr = cache::OBJECTS.get(post_id)?.attributed_to().id().ok()?;
cache::OBJECTS.get(&usr)
}

View file

@ -8,7 +8,7 @@ lazy_static::lazy_static! {
}
#[component]
pub fn ActorStrip(object: crate::Object) -> impl IntoView {
pub fn ActorStrip(object: crate::Doc) -> impl IntoView {
let actor_id = object.id().unwrap_or_default().to_string();
let username = object.preferred_username().unwrap_or_default().to_string();
let domain = object.id().unwrap_or_default().replace("https://", "").split('/').next().unwrap_or_default().to_string();
@ -21,7 +21,7 @@ pub fn ActorStrip(object: crate::Object) -> impl IntoView {
}
#[component]
pub fn ActorBanner(object: crate::Object) -> impl IntoView {
pub fn ActorBanner(object: crate::Doc) -> impl IntoView {
match object.as_ref() {
serde_json::Value::String(id) => view! {
<div><b>?</b>" "<a class="clean hover" href={Uri::web(U::Actor, id)}>{Uri::pretty(id, 50)}</a></div>

View file

@ -47,7 +47,7 @@ pub struct FiltersConfig {
}
impl FiltersConfig {
pub fn visible(&self, item: &crate::Object) -> bool {
pub fn visible(&self, item: &crate::Doc) -> bool {
use apb::{Object, Activity};
use crate::Cache;

View file

@ -26,12 +26,12 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
use std::{ops::Deref, sync::Arc};
use uriproxy::UriClass;
pub type Object = Arc<serde_json::Value>;
pub type Doc = Arc<serde_json::Value>;
pub mod cache {
use super::DashmapCache;
lazy_static::lazy_static! {
pub static ref OBJECTS: DashmapCache<super::Object> = DashmapCache::default();
pub static ref OBJECTS: DashmapCache<super::Doc> = DashmapCache::default();
pub static ref WEBFINGER: DashmapCache<String> = DashmapCache::default();
}
}
@ -92,8 +92,8 @@ impl<T> Cache for DashmapCache<T> {
}
}
impl DashmapCache<Object> {
pub async fn resolve(&self, key: &str, kind: UriClass, auth: Auth) -> Option<Object> {
impl DashmapCache<Doc> {
pub async fn resolve(&self, key: &str, kind: UriClass, auth: Auth) -> Option<Doc> {
let full_key = Uri::full(kind, key);
tracing::info!("resolving {key} -> {full_key}");
match self.get(&full_key) {
@ -120,8 +120,8 @@ impl DashmapCache<Object> {
// TODO would be cool unifying a bit the fetch code too
impl DashmapCache<Object> {
pub async fn fetch(&self, k: &str, kind: UriClass) -> reqwest::Result<Object> {
impl DashmapCache<Doc> {
pub async fn fetch(&self, k: &str, kind: UriClass) -> reqwest::Result<Doc> {
match self.get(k) {
Some(x) => Ok(x),
None => {

View file

@ -6,7 +6,7 @@ use crate::{prelude::*, URL_SENSITIVE};
use apb::{ActivityMut, Base, Collection, CollectionMut, Object, ObjectMut, Shortcuts};
#[component]
pub fn Object(object: crate::Object, #[prop(default = true)] controls: bool) -> impl IntoView {
pub fn Object(object: crate::Doc, #[prop(default = true)] controls: bool) -> impl IntoView {
let oid = object.id().unwrap_or_default().to_string();
let author_id = object.attributed_to().id().ok().unwrap_or_default();
let author = cache::OBJECTS.get_or(&author_id, serde_json::Value::String(author_id.clone()).into());

View file

@ -12,7 +12,7 @@ pub fn Loadable<El, V>(
children: Children,
) -> impl IntoView
where
El: Send + Sync + Fn(crate::Object) -> V + 'static,
El: Send + Sync + Fn(crate::Doc) -> V + 'static,
V: IntoView + 'static
{

View file

@ -56,7 +56,7 @@ fn FeedRecursive(tl: Timeline, root: String) -> impl IntoView {
None
}
})
.collect::<Vec<(String, crate::Object)>>();
.collect::<Vec<(String, crate::Doc)>>();
view! {
<For