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