Remove homebrew notification system. Will be using the spec for this.
This commit is contained in:
parent
1d50c5b1e4
commit
3b1dabd624
|
@ -4,41 +4,6 @@ import Json.Decode as Decode
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
import Dict exposing (Dict)
|
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 DirectMessages = Dict String String
|
||||||
type alias DirectMessagesRaw = Dict String (List String)
|
type alias DirectMessagesRaw = Dict String (List String)
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,6 @@ type alias Notification =
|
||||||
port sendNotificationPort : Notification -> Cmd msg
|
port sendNotificationPort : Notification -> Cmd msg
|
||||||
port onNotificationClickPort : (String -> msg) -> Sub msg
|
port onNotificationClickPort : (String -> msg) -> Sub msg
|
||||||
|
|
||||||
producesNotification : NotificationSetting -> RoomEvent -> Bool
|
|
||||||
producesNotification ns re = case ns of
|
|
||||||
Normal -> True
|
|
||||||
_ -> False
|
|
||||||
|
|
||||||
notificationText : RoomEvent -> String
|
notificationText : RoomEvent -> String
|
||||||
notificationText re = case (Decode.decodeValue (field "msgtype" string) re.content) of
|
notificationText re = case (Decode.decodeValue (field "msgtype" string) re.content) of
|
||||||
Ok "m.text" -> Result.withDefault "" <| (Decode.decodeValue (field "body" string) re.content)
|
Ok "m.text" -> Result.withDefault "" <| (Decode.decodeValue (field "body" string) re.content)
|
||||||
|
@ -30,6 +25,5 @@ joinedRoomNotificationEvents s =
|
||||||
in
|
in
|
||||||
List.sortBy (\(k, v) -> v.originServerTs)
|
List.sortBy (\(k, v) -> v.originServerTs)
|
||||||
<| Dict.foldl (\k v a -> a ++ applyPair k v) []
|
<| Dict.foldl (\k v a -> a ++ applyPair k v) []
|
||||||
<| Dict.map (\k v -> List.filter (producesNotification (roomIdNotificationSetting s k)) v)
|
|
||||||
<| joinedRoomsTimelineEvents s
|
<| joinedRoomsTimelineEvents s
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user