From dae4d98f54be49665fea3566e006a216cd73c997 Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Tue, 12 Jan 2021 21:06:13 +0000 Subject: [PATCH] Follow request notifications I'm not sure why the other clients don't have these. I want them! --- src/Command.elm | 8 ++++++++ src/Mastodon/Helper.elm | 1 + src/Mastodon/Model.elm | 2 +- src/View/Notification.elm | 12 +++++++++--- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Command.elm b/src/Command.elm index cf970b7..fea68ec 100644 --- a/src/Command.elm +++ b/src/Command.elm @@ -762,6 +762,14 @@ notifyNotification notification = , clickUrl = "#account/" ++ notification.account.id } + "follow_request" -> + Ports.notify + { title = notification.account.acct ++ " sent you a follow request" + , icon = notification.account.avatar + , body = notification.account.note + , clickUrl = "#account/" ++ notification.account.id + } + _ -> Cmd.none diff --git a/src/Mastodon/Helper.elm b/src/Mastodon/Helper.elm index 3af2817..8f3ef0c 100644 --- a/src/Mastodon/Helper.elm +++ b/src/Mastodon/Helper.elm @@ -176,6 +176,7 @@ aggregateNotifications notifications = , notifications |> only "favourite" |> groupWhile sameStatus |> aggregate , notifications |> only "mention" |> groupWhile sameStatus |> aggregate , notifications |> only "follow" |> groupWhile (\_ _ -> True) |> aggregate + , notifications |> only "follow_request" |> groupWhile (\_ _ -> True) |> aggregate ] |> List.concat |> List.sortBy .created_at diff --git a/src/Mastodon/Model.elm b/src/Mastodon/Model.elm index bb69707..dd1c519 100644 --- a/src/Mastodon/Model.elm +++ b/src/Mastodon/Model.elm @@ -166,7 +166,7 @@ type alias Mention = type alias Notification = {- - id: The notification ID - - type_: One of: "mention", "reblog", "favourite", "follow" + - type_: One of: "mention", "reblog", "favourite", "follow", "follow_request", "poll", "status" - created_at: The time the notification was created - account: The Account sending the notification to the user - status: The Status associated with the notification, if applicable diff --git a/src/View/Notification.elm b/src/View/Notification.elm index dda4b3e..fa16b12 100644 --- a/src/View/Notification.elm +++ b/src/View/Notification.elm @@ -47,7 +47,7 @@ filterNotifications filter notifications = type_ == "favourite" NotificationOnlyFollows -> - type_ == "follow" + type_ == "follow" || type_ == "follow_request" in if filter == NotificationAll then notifications @@ -105,7 +105,7 @@ notificationStatusView ( context, currentUser, status, { type_, accounts } ) = notificationFollowView : CurrentUser -> NotificationAggregate -> Html Msg -notificationFollowView currentUser { accounts } = +notificationFollowView currentUser { type_, accounts } = let profileView : AccountNotificationDate -> Html Msg profileView { account, created_at } = @@ -122,9 +122,15 @@ notificationFollowView currentUser { accounts } = , onClick <| Navigate ("#account/" ++ account.id) ] ] + + message = + if type_ == "follow_request" then + "sent you a follow request" + else + "started following you" in div [ class "notification follow" ] - [ notificationHeading accounts "started following you" "user" + [ notificationHeading accounts message "user" , div [ class "" ] <| List.map profileView (List.take 3 accounts) ]