add: ability to set home to stack

This commit is contained in:
trisua 2025-05-09 16:23:40 -04:00
parent 870289a5bb
commit 5df0ea6152
4 changed files with 31 additions and 13 deletions

View file

@ -71,6 +71,7 @@ pub enum DefaultTimelineChoice {
FollowingQuestions,
AllPosts,
AllQuestions,
Stack(String),
}
impl Default for DefaultTimelineChoice {
@ -81,16 +82,17 @@ impl Default for DefaultTimelineChoice {
impl DefaultTimelineChoice {
/// Get the relative URL that the timeline should bring you to.
pub fn relative_url(&self) -> &str {
pub fn relative_url(&self) -> String {
match &self {
Self::MyCommunities => "/",
Self::MyCommunitiesQuestions => "/questions",
Self::PopularPosts => "/popular",
Self::PopularQuestions => "/popular/questions",
Self::FollowingPosts => "/following",
Self::FollowingQuestions => "/following/questions",
Self::AllPosts => "/all",
Self::AllQuestions => "/all/questions",
Self::MyCommunities => "/".to_string(),
Self::MyCommunitiesQuestions => "/questions".to_string(),
Self::PopularPosts => "/popular".to_string(),
Self::PopularQuestions => "/popular/questions".to_string(),
Self::FollowingPosts => "/following".to_string(),
Self::FollowingQuestions => "/following/questions".to_string(),
Self::AllPosts => "/all".to_string(),
Self::AllQuestions => "/all/questions".to_string(),
Self::Stack(id) => format!("/stacks/{id}"),
}
}
}