chore(web): rename alias to Doc
now doesn't clash anymore
This commit is contained in:
parent
51ce2f5272
commit
4e667e9309
8 changed files with 15 additions and 15 deletions
|
@ -5,7 +5,7 @@ use apb::{Activity, ActivityMut, Base, Object};
|
||||||
|
|
||||||
|
|
||||||
#[component]
|
#[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 object_id = activity.object().id().unwrap_or_default();
|
||||||
let to = activity.to().all_ids();
|
let to = activity.to().all_ids();
|
||||||
let cc = activity.cc().all_ids();
|
let cc = activity.cc().all_ids();
|
||||||
|
@ -46,7 +46,7 @@ pub fn ActivityLine(activity: crate::Object, children: Children) -> impl IntoVie
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Item(
|
pub fn Item(
|
||||||
item: crate::Object,
|
item: crate::Doc,
|
||||||
#[prop(optional)] sep: bool,
|
#[prop(optional)] sep: bool,
|
||||||
#[prop(optional)] slim: bool,
|
#[prop(optional)] slim: bool,
|
||||||
#[prop(optional)] always: bool,
|
#[prop(optional)] always: bool,
|
||||||
|
|
|
@ -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()?;
|
let usr = cache::OBJECTS.get(post_id)?.attributed_to().id().ok()?;
|
||||||
cache::OBJECTS.get(&usr)
|
cache::OBJECTS.get(&usr)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ lazy_static::lazy_static! {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[component]
|
#[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 actor_id = object.id().unwrap_or_default().to_string();
|
||||||
let username = object.preferred_username().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();
|
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]
|
#[component]
|
||||||
pub fn ActorBanner(object: crate::Object) -> impl IntoView {
|
pub fn ActorBanner(object: crate::Doc) -> impl IntoView {
|
||||||
match object.as_ref() {
|
match object.as_ref() {
|
||||||
serde_json::Value::String(id) => view! {
|
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>
|
<div><b>?</b>" "<a class="clean hover" href={Uri::web(U::Actor, id)}>{Uri::pretty(id, 50)}</a></div>
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub struct FiltersConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FiltersConfig {
|
impl FiltersConfig {
|
||||||
pub fn visible(&self, item: &crate::Object) -> bool {
|
pub fn visible(&self, item: &crate::Doc) -> bool {
|
||||||
use apb::{Object, Activity};
|
use apb::{Object, Activity};
|
||||||
use crate::Cache;
|
use crate::Cache;
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
use std::{ops::Deref, sync::Arc};
|
use std::{ops::Deref, sync::Arc};
|
||||||
use uriproxy::UriClass;
|
use uriproxy::UriClass;
|
||||||
|
|
||||||
pub type Object = Arc<serde_json::Value>;
|
pub type Doc = Arc<serde_json::Value>;
|
||||||
|
|
||||||
pub mod cache {
|
pub mod cache {
|
||||||
use super::DashmapCache;
|
use super::DashmapCache;
|
||||||
lazy_static::lazy_static! {
|
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();
|
pub static ref WEBFINGER: DashmapCache<String> = DashmapCache::default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,8 +92,8 @@ impl<T> Cache for DashmapCache<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DashmapCache<Object> {
|
impl DashmapCache<Doc> {
|
||||||
pub async fn resolve(&self, key: &str, kind: UriClass, auth: Auth) -> Option<Object> {
|
pub async fn resolve(&self, key: &str, kind: UriClass, auth: Auth) -> Option<Doc> {
|
||||||
let full_key = Uri::full(kind, key);
|
let full_key = Uri::full(kind, key);
|
||||||
tracing::info!("resolving {key} -> {full_key}");
|
tracing::info!("resolving {key} -> {full_key}");
|
||||||
match self.get(&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
|
// TODO would be cool unifying a bit the fetch code too
|
||||||
|
|
||||||
impl DashmapCache<Object> {
|
impl DashmapCache<Doc> {
|
||||||
pub async fn fetch(&self, k: &str, kind: UriClass) -> reqwest::Result<Object> {
|
pub async fn fetch(&self, k: &str, kind: UriClass) -> reqwest::Result<Doc> {
|
||||||
match self.get(k) {
|
match self.get(k) {
|
||||||
Some(x) => Ok(x),
|
Some(x) => Ok(x),
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{prelude::*, URL_SENSITIVE};
|
||||||
use apb::{ActivityMut, Base, Collection, CollectionMut, Object, ObjectMut, Shortcuts};
|
use apb::{ActivityMut, Base, Collection, CollectionMut, Object, ObjectMut, Shortcuts};
|
||||||
|
|
||||||
#[component]
|
#[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 oid = object.id().unwrap_or_default().to_string();
|
||||||
let author_id = object.attributed_to().id().ok().unwrap_or_default();
|
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());
|
let author = cache::OBJECTS.get_or(&author_id, serde_json::Value::String(author_id.clone()).into());
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub fn Loadable<El, V>(
|
||||||
children: Children,
|
children: Children,
|
||||||
) -> impl IntoView
|
) -> impl IntoView
|
||||||
where
|
where
|
||||||
El: Send + Sync + Fn(crate::Object) -> V + 'static,
|
El: Send + Sync + Fn(crate::Doc) -> V + 'static,
|
||||||
V: IntoView + 'static
|
V: IntoView + 'static
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ fn FeedRecursive(tl: Timeline, root: String) -> impl IntoView {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<(String, crate::Object)>>();
|
.collect::<Vec<(String, crate::Doc)>>();
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<For
|
<For
|
||||||
|
|
Loading…
Add table
Reference in a new issue