From 3b1dabd624f971f9bb3de42cf5f01bd2aa5d23f3 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sat, 7 Sep 2019 18:28:58 -0700 Subject: [PATCH] Remove homebrew notification system. Will be using the spec for this. --- src/Scylla/AccountData.elm | 35 ----------------------------------- src/Scylla/Notification.elm | 6 ------ 2 files changed, 41 deletions(-) diff --git a/src/Scylla/AccountData.elm b/src/Scylla/AccountData.elm index 54e90eb..52f2356 100644 --- a/src/Scylla/AccountData.elm +++ b/src/Scylla/AccountData.elm @@ -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) diff --git a/src/Scylla/Notification.elm b/src/Scylla/Notification.elm index 62f3bd2..f659b15 100644 --- a/src/Scylla/Notification.elm +++ b/src/Scylla/Notification.elm @@ -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