@@ -6,7 +6,7 @@ import Html exposing (Html, div, footer, h1, h2, h4, span, strong, text)
66import Html.Attributes exposing (class , classList )
77import Json.Decode as Decode exposing (string )
88import Json.Decode.Pipeline exposing (optional , required )
9- import Lib.HttpApi as HttpApi
9+ import Lib.HttpApi as HttpApi exposing ( HttpResult )
1010import RemoteData exposing (RemoteData (..) , WebData )
1111import Set exposing (Set )
1212import UI
@@ -105,9 +105,13 @@ type Msg
105105 | FetchAllNotificationsFinished ( WebData PaginatedNotifications )
106106 | ToggleSelection Notification
107107 | MarkSelectionAsUnread
108+ | MarkNotificationsAsUnreadFinished ( HttpResult () )
108109 | MarkSelectionAsRead
110+ | MarkNotificationsAsReadFinished ( HttpResult () )
109111 | ArchiveSelection
112+ | MarkNotificationsAsArchivedFinished ( HttpResult () )
110113 | UnarchiveSelection
114+ | MarkNotificationsAsUnarchivedFinished ( HttpResult () )
111115
112116
113117update : AppContext -> NotificationsRoute -> Account a -> Msg -> Model -> ( Model , Cmd Msg )
@@ -233,24 +237,50 @@ fetchNotifications_ appContext account status paginationCursorParam =
233237 |> HttpApi . perform appContext. api
234238
235239
236- markNotificationsAsRead : AppContext -> Account a -> Cmd Msg
237- markNotificationsAsRead _ _ =
238- Cmd . none
239-
240-
241- markNotificationsAsUnread : AppContext -> Account a -> Cmd Msg
242- markNotificationsAsUnread _ _ =
243- Cmd . none
244-
245-
246- archiveNotifications : AppContext -> Account a -> Cmd Msg
247- archiveNotifications _ _ =
248- Cmd . none
249-
250-
251- unarchiveNotifications : AppContext -> Account a -> Cmd Msg
252- unarchiveNotifications _ _ =
253- Cmd . none
240+ markNotificationsAsRead : AppContext -> Account a -> List String -> Cmd Msg
241+ markNotificationsAsRead appContext account notificationIds =
242+ updateNotificationStatuses
243+ MarkNotificationsAsReadFinished
244+ appContext
245+ account
246+ notificationIds
247+ Notification . Read
248+
249+
250+ markNotificationsAsUnread : AppContext -> Account a -> List String -> Cmd Msg
251+ markNotificationsAsUnread appContext account notificationIds =
252+ updateNotificationStatuses
253+ MarkNotificationsAsUnreadFinished
254+ appContext
255+ account
256+ notificationIds
257+ Notification . Unread
258+
259+
260+ archiveNotifications : AppContext -> Account a -> List String -> Cmd Msg
261+ archiveNotifications appContext account notificationIds =
262+ updateNotificationStatuses
263+ MarkNotificationsAsArchivedFinished
264+ appContext
265+ account
266+ notificationIds
267+ Notification . Archived
268+
269+
270+ unarchiveNotifications : AppContext -> Account a -> List String -> Cmd Msg
271+ unarchiveNotifications appContext account notificationIds =
272+ updateNotificationStatuses MarkNotificationsAsUnarchivedFinished
273+ appContext
274+ account
275+ notificationIds
276+ Notification . Unread
277+
278+
279+ updateNotificationStatuses : (HttpResult () -> Msg ) -> AppContext -> Account a -> List String -> Notification .NotificationStatus -> Cmd Msg
280+ updateNotificationStatuses toMsg appContext account notificationIds status =
281+ ShareApi . updateNotificationStatuses account notificationIds status
282+ |> HttpApi . toRequestWithEmptyResponse toMsg
283+ |> HttpApi . perform appContext. api
254284
255285
256286
0 commit comments