Fix #58: Add a direct message filter button.

This commit is contained in:
Nicolas Perriault 2017-05-13 13:57:44 +02:00
parent 1fc6d6b4a2
commit 93e42ac575
No known key found for this signature in database
GPG Key ID: DA5E4C83904F7A2A
2 changed files with 26 additions and 12 deletions

View File

@ -153,6 +153,7 @@ type alias Draft =
type NotificationFilter
= NotificationAll
| NotificationOnlyMentions
| NotificationOnlyDirect
| NotificationOnlyBoosts
| NotificationOnlyFavourites
| NotificationOnlyFollows

View File

@ -20,22 +20,34 @@ type alias CurrentUser =
filterNotifications : NotificationFilter -> List NotificationAggregate -> List NotificationAggregate
filterNotifications filter notifications =
let
applyFilter { type_ } =
case filter of
NotificationAll ->
True
applyFilter { type_, status } =
let
visibility =
case status of
Just status ->
status.visibility
NotificationOnlyMentions ->
type_ == "mention"
Nothing ->
""
in
case filter of
NotificationAll ->
True
NotificationOnlyBoosts ->
type_ == "reblog"
NotificationOnlyMentions ->
type_ == "mention" && visibility /= "direct"
NotificationOnlyFavourites ->
type_ == "favourite"
NotificationOnlyDirect ->
type_ == "mention" && visibility == "direct"
NotificationOnlyFollows ->
type_ == "follow"
NotificationOnlyBoosts ->
type_ == "reblog"
NotificationOnlyFavourites ->
type_ == "favourite"
NotificationOnlyFollows ->
type_ == "follow"
in
if filter == NotificationAll then
notifications
@ -124,6 +136,7 @@ notificationFilterView filter =
Common.justifiedButtonGroup "notification-filters"
[ filterBtn "All notifications" "asterisk" NotificationAll
, filterBtn "Mentions" "share-alt" NotificationOnlyMentions
, filterBtn "Direct" "envelope" NotificationOnlyDirect
, filterBtn "Boosts" "fire" NotificationOnlyBoosts
, filterBtn "Favorites" "star" NotificationOnlyFavourites
, filterBtn "Follows" "user" NotificationOnlyFollows