chiark / gitweb /
Improve OtherUserOptionsMenu's handling of follow requests.
authorSimon Tatham <anakin@pobox.com>
Sat, 3 Feb 2024 10:40:36 +0000 (10:40 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 3 Feb 2024 10:40:36 +0000 (10:40 +0000)
Now, when the target account is locked, the 'Follow this user' menu
option is reworded as 'Request to follow this user'.

src/client.rs
src/options.rs

index a46d18f76e6b42a0ad1777171c2e0ed1edd68a20..a064416c2a73b3dde99a78c182fa0de392aed99a 100644 (file)
@@ -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 {
index 9be67ae1f0737720b917424f63056f9becf55495..58d2d44649d611c20af7bc764c29f23a5676a5e2 100644 (file)
@@ -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,