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