From: Simon Tatham Date: Sat, 3 Feb 2024 10:40:36 +0000 (+0000) Subject: Improve OtherUserOptionsMenu's handling of follow requests. X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=01e66841cf6209826c5c035cda0dd0ef3f44dafb;p=mastodonochrome.git Improve OtherUserOptionsMenu's handling of follow requests. Now, when the target account is locked, the 'Follow this user' menu option is reworded as 'Request to follow this user'. --- diff --git a/src/client.rs b/src/client.rs index a46d18f..a064416 100644 --- a/src/client.rs +++ b/src/client.rs @@ -91,6 +91,13 @@ impl ErrorLog { } } +/// The details of how you are following a user, or attempting to. +/// +/// If the user's account is locked, then there's a third possible +/// state, which is that you have _requested_ to follow them and they +/// haven't yet given or refused permission. That's represented here +/// just as 'Following', because the same API request is used to get +/// into that state. #[derive(Debug, PartialEq, Eq, Clone)] pub enum Followness { NotFollowing, @@ -102,7 +109,7 @@ pub enum Followness { impl Followness { pub fn from_rel(rel: &Relationship) -> Followness { - if !rel.following { + if !rel.following && !rel.requested { Followness::NotFollowing } else { let boosts = if rel.showing_reblogs { diff --git a/src/options.rs b/src/options.rs index 9be67ae..58d2d44 100644 --- a/src/options.rs +++ b/src/options.rs @@ -354,15 +354,33 @@ impl OtherUserOptionsMenu { let edit_status = FileStatusLine::new() .message("Edit line and press Return") .finalise(); + + let prev_follow = Followness::from_rel(&rel); + + // The 'follow this user' request should be renamed 'Request + // to follow', if the account is locked and we're not already + // following it. But in both other cases (if we aren't + // following it but can do so unilaterally, or if we _are_ so + // that we can unfollow unilaterally), call it just 'follow'. + // + // The 'request' wording should therefore also show up if + // we've already requested to follow this user but it isn't + // confirmed yet. + let follow_wording = if ac.locked && !rel.following { + "Request to follow this user: " + } else { + "Follow this user: " + }; let cl_follow = CyclingMenuLine::new( Pr('F'), - ColouredString::plain("Follow this user: "), + ColouredString::plain(follow_wording), &[ (false, ColouredString::plain("no")), (true, ColouredString::uniform("yes", 'f')), ], - rel.following, + prev_follow != Followness::NotFollowing, ); + let boosts = if rel.following { if rel.showing_reblogs { Boosts::Show @@ -410,8 +428,6 @@ impl OtherUserOptionsMenu { rel.muting, ); - let prev_follow = Followness::from_rel(&rel); - let mut menu = OtherUserOptionsMenu { title, normal_status,