chore: run cargo format
This commit is contained in:
parent
0540bb3ae2
commit
7908213245
|
@ -1,5 +1,8 @@
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::{CommunityResponse, FollowCommunity, GetCommunity, GetCommunityResponse, BlockCommunityResponse, BlockCommunity},
|
community::{
|
||||||
|
BlockCommunity, BlockCommunityResponse, CommunityResponse, FollowCommunity, GetCommunity,
|
||||||
|
GetCommunityResponse,
|
||||||
|
},
|
||||||
lemmy_db_schema::newtypes::CommunityId,
|
lemmy_db_schema::newtypes::CommunityId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@ pub fn fetch_instances(query_filter: &str) -> std::result::Result<Vec<Instance>,
|
||||||
.filter(|instance| {
|
.filter(|instance| {
|
||||||
instance.software == Some("lemmy".to_owned())
|
instance.software == Some("lemmy".to_owned())
|
||||||
&& instance.domain.clone().contains(&lowercase_query_filter)
|
&& instance.domain.clone().contains(&lowercase_query_filter)
|
||||||
}).cloned()
|
})
|
||||||
|
.cloned()
|
||||||
.collect::<Vec<Instance>>()),
|
.collect::<Vec<Instance>>()),
|
||||||
None => Ok(vec![]),
|
None => Ok(vec![]),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
lemmy_db_schema::{newtypes::PersonId, CommentSortType},
|
lemmy_db_schema::{newtypes::PersonId, CommentSortType},
|
||||||
person::{
|
person::{
|
||||||
GetPersonDetails, GetPersonDetailsResponse, GetPersonMentions, GetPersonMentionsResponse,
|
BlockPerson, BlockPersonResponse, GetPersonDetails, GetPersonDetailsResponse,
|
||||||
GetReplies, GetRepliesResponse, MarkAllAsRead, BlockPersonResponse, BlockPerson,
|
GetPersonMentions, GetPersonMentionsResponse, GetReplies, GetRepliesResponse,
|
||||||
|
MarkAllAsRead,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,8 @@ use crate::{
|
||||||
};
|
};
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
lemmy_db_schema::{SubscribedType, SortType}, lemmy_db_views::structs::PostView,
|
lemmy_db_schema::{SortType, SubscribedType},
|
||||||
|
lemmy_db_views::structs::PostView,
|
||||||
lemmy_db_views_actor::structs::CommunityView,
|
lemmy_db_views_actor::structs::CommunityView,
|
||||||
};
|
};
|
||||||
use relm4::{factory::FactoryVecDeque, prelude::*};
|
use relm4::{factory::FactoryVecDeque, prelude::*};
|
||||||
|
@ -12,7 +13,10 @@ use relm4_components::web_image::WebImage;
|
||||||
|
|
||||||
use crate::{api, settings, util::get_web_image_msg};
|
use crate::{api, settings, util::get_web_image_msg};
|
||||||
|
|
||||||
use super::{post_row::PostRow, sort_dropdown::{SortDropdown, SortDropdownOutput}};
|
use super::{
|
||||||
|
post_row::PostRow,
|
||||||
|
sort_dropdown::{SortDropdown, SortDropdownOutput},
|
||||||
|
};
|
||||||
|
|
||||||
pub struct CommunityPage {
|
pub struct CommunityPage {
|
||||||
info: CommunityView,
|
info: CommunityView,
|
||||||
|
@ -165,10 +169,11 @@ impl SimpleComponent for CommunityPage {
|
||||||
) -> relm4::ComponentParts<Self> {
|
) -> relm4::ComponentParts<Self> {
|
||||||
let avatar = WebImage::builder().launch("".to_string()).detach();
|
let avatar = WebImage::builder().launch("".to_string()).detach();
|
||||||
let posts = FactoryVecDeque::new(gtk::Box::default(), sender.output_sender());
|
let posts = FactoryVecDeque::new(gtk::Box::default(), sender.output_sender());
|
||||||
let sort_dropdown = SortDropdown::builder().launch(()).forward(sender.input_sender(), |msg| {
|
let sort_dropdown =
|
||||||
match msg {
|
SortDropdown::builder()
|
||||||
|
.launch(())
|
||||||
|
.forward(sender.input_sender(), |msg| match msg {
|
||||||
SortDropdownOutput::New(sort_order) => CommunityInput::UpdateOrder(sort_order),
|
SortDropdownOutput::New(sort_order) => CommunityInput::UpdateOrder(sort_order),
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let dialog = EditorDialog::builder()
|
let dialog = EditorDialog::builder()
|
||||||
|
@ -215,7 +220,8 @@ impl SimpleComponent for CommunityPage {
|
||||||
self.current_posts_page += 1;
|
self.current_posts_page += 1;
|
||||||
let page = self.current_posts_page;
|
let page = self.current_posts_page;
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let community_posts = api::posts::list_posts(page, Some(name), None, Some(sort_type));
|
let community_posts =
|
||||||
|
api::posts::list_posts(page, Some(name), None, Some(sort_type));
|
||||||
if let Ok(community_posts) = community_posts {
|
if let Ok(community_posts) = community_posts {
|
||||||
sender.input(CommunityInput::DoneFetchPosts(community_posts));
|
sender.input(CommunityInput::DoneFetchPosts(community_posts));
|
||||||
}
|
}
|
||||||
|
@ -257,7 +263,7 @@ impl SimpleComponent for CommunityPage {
|
||||||
sender.input(CommunityInput::UpdateSubscriptionState(
|
sender.input(CommunityInput::UpdateSubscriptionState(
|
||||||
community.community_view.subscribed,
|
community.community_view.subscribed,
|
||||||
));
|
));
|
||||||
},
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("{}", err);
|
println!("{}", err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,9 @@ impl FactoryComponent for CommunityRow {
|
||||||
|
|
||||||
fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
|
fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
|
||||||
match message {
|
match message {
|
||||||
CommunityRowMsg::OpenCommunity => sender.output(crate::AppMsg::OpenCommunity(
|
CommunityRowMsg::OpenCommunity => {
|
||||||
self.community.community.id,
|
sender.output(crate::AppMsg::OpenCommunity(self.community.community.id))
|
||||||
)),
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use relm4::prelude::*;
|
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
use relm4::prelude::*;
|
||||||
|
|
||||||
#[relm4::widget_template(pub)]
|
#[relm4::widget_template(pub)]
|
||||||
impl WidgetTemplate for LoadingIndicator {
|
impl WidgetTemplate for LoadingIndicator {
|
||||||
|
|
|
@ -160,9 +160,7 @@ impl FactoryComponent for MentionRow {
|
||||||
sender.output(crate::AppMsg::OpenPost(self.comment.post.id));
|
sender.output(crate::AppMsg::OpenPost(self.comment.post.id));
|
||||||
}
|
}
|
||||||
MentionRowMsg::OpenCommunity => {
|
MentionRowMsg::OpenCommunity => {
|
||||||
sender.output(crate::AppMsg::OpenCommunity(
|
sender.output(crate::AppMsg::OpenCommunity(self.comment.community.id));
|
||||||
self.comment.community.id,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,9 +106,9 @@ impl FactoryComponent for ModeratesRow {
|
||||||
|
|
||||||
fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
|
fn update(&mut self, message: Self::Input, sender: FactorySender<Self>) {
|
||||||
match message {
|
match message {
|
||||||
ModeratesRowMsg::OpenCommunity => sender.output(crate::AppMsg::OpenCommunity(
|
ModeratesRowMsg::OpenCommunity => {
|
||||||
self.community.community.id,
|
sender.output(crate::AppMsg::OpenCommunity(self.community.community.id))
|
||||||
)),
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,9 +194,7 @@ impl FactoryComponent for PostRow {
|
||||||
PostRowMsg::OpenPerson => {
|
PostRowMsg::OpenPerson => {
|
||||||
sender.output(crate::AppMsg::OpenPerson(self.post.creator.id))
|
sender.output(crate::AppMsg::OpenPerson(self.post.creator.id))
|
||||||
}
|
}
|
||||||
PostRowMsg::OpenPost => {
|
PostRowMsg::OpenPost => sender.output(crate::AppMsg::OpenPost(self.post.post.id)),
|
||||||
sender.output(crate::AppMsg::OpenPost(self.post.post.id))
|
|
||||||
}
|
|
||||||
PostRowMsg::ToggleSaved => {
|
PostRowMsg::ToggleSaved => {
|
||||||
let post_id = self.post.post.id;
|
let post_id = self.post.post.id;
|
||||||
let new_state = !self.post.saved;
|
let new_state = !self.post.saved;
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use lemmy_api_common::{lemmy_db_schema::{ListingType, SortType}, lemmy_db_views::structs::PostView};
|
use lemmy_api_common::{
|
||||||
|
lemmy_db_schema::{ListingType, SortType},
|
||||||
|
lemmy_db_views::structs::PostView,
|
||||||
|
};
|
||||||
use relm4::{factory::FactoryVecDeque, prelude::*};
|
use relm4::{factory::FactoryVecDeque, prelude::*};
|
||||||
|
|
||||||
use crate::api;
|
use crate::api;
|
||||||
|
|
||||||
use super::{post_row::PostRow, sort_dropdown::{SortDropdown, SortDropdownOutput}};
|
use super::{
|
||||||
|
post_row::PostRow,
|
||||||
|
sort_dropdown::{SortDropdown, SortDropdownOutput},
|
||||||
|
};
|
||||||
|
|
||||||
pub struct PostsPage {
|
pub struct PostsPage {
|
||||||
sort_dropdown: Controller<SortDropdown>,
|
sort_dropdown: Controller<SortDropdown>,
|
||||||
|
@ -86,10 +92,11 @@ impl SimpleComponent for PostsPage {
|
||||||
root: &Self::Root,
|
root: &Self::Root,
|
||||||
sender: ComponentSender<Self>,
|
sender: ComponentSender<Self>,
|
||||||
) -> ComponentParts<Self> {
|
) -> ComponentParts<Self> {
|
||||||
let sort_dropdown = SortDropdown::builder().launch(()).forward(sender.input_sender(), |msg| {
|
let sort_dropdown =
|
||||||
match msg {
|
SortDropdown::builder()
|
||||||
|
.launch(())
|
||||||
|
.forward(sender.input_sender(), |msg| match msg {
|
||||||
SortDropdownOutput::New(sort_order) => PostsPageInput::UpdateOrder(sort_order),
|
SortDropdownOutput::New(sort_order) => PostsPageInput::UpdateOrder(sort_order),
|
||||||
}
|
|
||||||
});
|
});
|
||||||
let posts = FactoryVecDeque::new(gtk::Box::default(), sender.output_sender());
|
let posts = FactoryVecDeque::new(gtk::Box::default(), sender.output_sender());
|
||||||
let model = Self {
|
let model = Self {
|
||||||
|
@ -146,7 +153,11 @@ impl SimpleComponent for PostsPage {
|
||||||
}
|
}
|
||||||
PostsPageInput::UpdateOrder(order) => {
|
PostsPageInput::UpdateOrder(order) => {
|
||||||
self.posts_order = order;
|
self.posts_order = order;
|
||||||
sender.input_sender().emit(PostsPageInput::FetchPosts(self.posts_type, order, true));
|
sender.input_sender().emit(PostsPageInput::FetchPosts(
|
||||||
|
self.posts_type,
|
||||||
|
order,
|
||||||
|
true,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,16 +239,14 @@ impl SimpleComponent for ProfilePage {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
ProfileInput::BlockUser => {
|
ProfileInput::BlockUser => {
|
||||||
let person_id = self.info.person_view.person.id;
|
let person_id = self.info.person_view.person.id;
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || match api::user::block_user(person_id, true) {
|
||||||
match api::user::block_user(person_id, true) {
|
|
||||||
Ok(_resp) => {}
|
Ok(_resp) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("{}", err);
|
println!("{}", err);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,17 +106,16 @@ impl SimpleComponent for VotingRowModel {
|
||||||
match message {
|
match message {
|
||||||
VotingRowInput::Vote(vote) => {
|
VotingRowInput::Vote(vote) => {
|
||||||
let mut score = self.stats.own_vote.unwrap_or(0) + vote;
|
let mut score = self.stats.own_vote.unwrap_or(0) + vote;
|
||||||
if !(-1..=1).contains(&score) { score = 0 };
|
if !(-1..=1).contains(&score) {
|
||||||
|
score = 0
|
||||||
|
};
|
||||||
if settings::get_current_account().jwt.is_none() {
|
if settings::get_current_account().jwt.is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let stats = self.stats.clone();
|
let stats = self.stats.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
let info = if stats.post_id.is_some() {
|
let info = if stats.post_id.is_some() {
|
||||||
let response = api::post::like_post(
|
let response = api::post::like_post(PostId(stats.post_id.unwrap()), score);
|
||||||
PostId(stats.post_id.unwrap()),
|
|
||||||
score,
|
|
||||||
);
|
|
||||||
match response {
|
match response {
|
||||||
Ok(post) => Some(VotingStats::from_post(
|
Ok(post) => Some(VotingStats::from_post(
|
||||||
post.post_view.counts,
|
post.post_view.counts,
|
||||||
|
@ -128,10 +127,8 @@ impl SimpleComponent for VotingRowModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let response = api::comment::like_comment(
|
let response =
|
||||||
CommentId(stats.comment_id.unwrap()),
|
api::comment::like_comment(CommentId(stats.comment_id.unwrap()), score);
|
||||||
score,
|
|
||||||
);
|
|
||||||
match response {
|
match response {
|
||||||
Ok(comment) => Some(VotingStats::from_comment(
|
Ok(comment) => Some(VotingStats::from_comment(
|
||||||
comment.comment_view.counts,
|
comment.comment_view.counts,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
use crate::components::loading_indicator::LoadingIndicator;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use lemmy_api_common::site::GetSiteResponse;
|
use lemmy_api_common::site::GetSiteResponse;
|
||||||
use relm4::prelude::*;
|
use relm4::prelude::*;
|
||||||
use crate::components::loading_indicator::LoadingIndicator;
|
|
||||||
|
|
||||||
use crate::api;
|
use crate::api;
|
||||||
|
|
||||||
|
@ -54,7 +54,11 @@ impl SimpleComponent for SiteInfo {
|
||||||
root: &Self::Root,
|
root: &Self::Root,
|
||||||
sender: ComponentSender<Self>,
|
sender: ComponentSender<Self>,
|
||||||
) -> ComponentParts<Self> {
|
) -> ComponentParts<Self> {
|
||||||
let model = Self { visible: false, loading: true, site_info: api::site::default_site_info() };
|
let model = Self {
|
||||||
|
visible: false,
|
||||||
|
loading: true,
|
||||||
|
site_info: api::site::default_site_info(),
|
||||||
|
};
|
||||||
let widgets = view_output!();
|
let widgets = view_output!();
|
||||||
ComponentParts { model, widgets }
|
ComponentParts { model, widgets }
|
||||||
}
|
}
|
||||||
|
@ -64,14 +68,14 @@ impl SimpleComponent for SiteInfo {
|
||||||
SiteInfoInput::Fetch => {
|
SiteInfoInput::Fetch => {
|
||||||
self.loading = true;
|
self.loading = true;
|
||||||
self.visible = true;
|
self.visible = true;
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || match api::site::fetch_site() {
|
||||||
match api::site::fetch_site() {
|
|
||||||
Ok(site_info) => sender.input(SiteInfoInput::Update(site_info)),
|
Ok(site_info) => sender.input(SiteInfoInput::Update(site_info)),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
sender.output_sender().emit(crate::AppMsg::ShowMessage(err.to_string()));
|
sender
|
||||||
|
.output_sender()
|
||||||
|
.emit(crate::AppMsg::ShowMessage(err.to_string()));
|
||||||
sender.input_sender().emit(SiteInfoInput::Hide);
|
sender.input_sender().emit(SiteInfoInput::Hide);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
SiteInfoInput::Update(site_info) => {
|
SiteInfoInput::Update(site_info) => {
|
||||||
|
|
|
@ -17,7 +17,10 @@ use components::{
|
||||||
posts_page::{PostsPage, PostsPageInput},
|
posts_page::{PostsPage, PostsPageInput},
|
||||||
profile_page::{ProfileInput, ProfilePage},
|
profile_page::{ProfileInput, ProfilePage},
|
||||||
};
|
};
|
||||||
use dialogs::{about::AboutDialog, site_info::{SiteInfo, SiteInfoInput}};
|
use dialogs::{
|
||||||
|
about::AboutDialog,
|
||||||
|
site_info::{SiteInfo, SiteInfoInput},
|
||||||
|
};
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
community::GetCommunityResponse,
|
community::GetCommunityResponse,
|
||||||
|
|
Loading…
Reference in New Issue