Dedupe multiple account references in notifs. (#101)

This commit is contained in:
Nicolas Perriault 2017-04-28 19:08:46 +02:00 committed by GitHub
parent 29b053b130
commit 3ea6aaade2
3 changed files with 16 additions and 2 deletions

View File

@ -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 :: _ ->

View File

@ -198,6 +198,14 @@ notifications =
]
duplicateAccountNotifications : List Notification
duplicateAccountNotifications =
[ notificationSkroFollowsVjousse
, notificationSkroFollowsVjousse
, notificationSkroFollowsVjousse
]
notificationAggregates : List NotificationAggregate
notificationAggregates =
[ { type_ = "mention"

View File

@ -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