Remove homebrew notification system. Will be using the spec for this.

This commit is contained in:
Danila Fedorin 2019-09-07 18:28:58 -07:00
parent 1d50c5b1e4
commit 3b1dabd624
2 changed files with 0 additions and 41 deletions

View File

@ -4,41 +4,6 @@ import Json.Decode as Decode
import Json.Encode as Encode
import Dict exposing (Dict)
type NotificationSetting = Normal | MentionsOnly | None
encodeNotificationSetting : NotificationSetting -> Decode.Value
encodeNotificationSetting ns =
let
string = case ns of
Normal -> "Normal"
MentionsOnly -> "MentionsOnly"
None -> "None"
in
Encode.string string
notificationSettingDecoder : Decode.Decoder NotificationSetting
notificationSettingDecoder =
let
checkString s = case s of
"Normal" -> Decode.succeed Normal
"MentionsOnly" -> Decode.succeed MentionsOnly
"None" -> Decode.succeed None
_ -> Decode.fail "Not a valid notification setting"
in
Decode.andThen checkString Decode.string
roomNotificationSetting : JoinedRoom -> NotificationSetting
roomNotificationSetting jr = Maybe.withDefault Normal
<| Maybe.andThen Result.toMaybe
<| Maybe.map (Decode.decodeValue notificationSettingDecoder)
<| roomAccountData jr "com.danilafe.scylla.notifications"
roomIdNotificationSetting : SyncResponse -> String -> NotificationSetting
roomIdNotificationSetting sr s = Maybe.withDefault Normal
<| Maybe.map roomNotificationSetting
<| Maybe.andThen (Dict.get s)
<| Maybe.andThen .join sr.rooms
type alias DirectMessages = Dict String String
type alias DirectMessagesRaw = Dict String (List String)

View File

@ -13,11 +13,6 @@ type alias Notification =
port sendNotificationPort : Notification -> Cmd msg
port onNotificationClickPort : (String -> msg) -> Sub msg
producesNotification : NotificationSetting -> RoomEvent -> Bool
producesNotification ns re = case ns of
Normal -> True
_ -> False
notificationText : RoomEvent -> String
notificationText re = case (Decode.decodeValue (field "msgtype" string) re.content) of
Ok "m.text" -> Result.withDefault "" <| (Decode.decodeValue (field "body" string) re.content)
@ -30,6 +25,5 @@ joinedRoomNotificationEvents s =
in
List.sortBy (\(k, v) -> v.originServerTs)
<| Dict.foldl (\k v a -> a ++ applyPair k v) []
<| Dict.map (\k v -> List.filter (producesNotification (roomIdNotificationSetting s k)) v)
<| joinedRoomsTimelineEvents s