Dedupe multiple account references in notifs. (#101)
This commit is contained in:
parent
29b053b130
commit
3ea6aaade2
@ -6,7 +6,7 @@ module Mastodon.Helper
|
||||
, notificationToAggregate
|
||||
)
|
||||
|
||||
import List.Extra exposing (groupWhile)
|
||||
import List.Extra exposing (groupWhile, uniqueBy)
|
||||
import Mastodon.Model
|
||||
exposing
|
||||
( Notification
|
||||
@ -114,7 +114,7 @@ aggregateNotifications notifications =
|
||||
extractAggregate statusGroup =
|
||||
let
|
||||
accounts =
|
||||
List.map .account statusGroup
|
||||
statusGroup |> List.map .account |> uniqueBy .id
|
||||
in
|
||||
case statusGroup of
|
||||
notification :: _ ->
|
||||
|
@ -198,6 +198,14 @@ notifications =
|
||||
]
|
||||
|
||||
|
||||
duplicateAccountNotifications : List Notification
|
||||
duplicateAccountNotifications =
|
||||
[ notificationSkroFollowsVjousse
|
||||
, notificationSkroFollowsVjousse
|
||||
, notificationSkroFollowsVjousse
|
||||
]
|
||||
|
||||
|
||||
notificationAggregates : List NotificationAggregate
|
||||
notificationAggregates =
|
||||
[ { type_ = "mention"
|
||||
|
@ -26,6 +26,12 @@ all =
|
||||
, created_at = "2017-04-24T20:13:47.431Z"
|
||||
}
|
||||
]
|
||||
, test "Dedupes aggregated accounts" <|
|
||||
\() ->
|
||||
Fixtures.duplicateAccountNotifications
|
||||
|> Mastodon.Helper.aggregateNotifications
|
||||
|> List.map (.accounts >> List.length)
|
||||
|> Expect.equal [ 1 ]
|
||||
, test "Add follows notification to aggregate" <|
|
||||
\() ->
|
||||
Fixtures.notifications
|
||||
|
Loading…
Reference in New Issue
Block a user