@@ -6,7 +6,7 @@ import Html exposing (Html, div, footer, h1, h2, h4, span, strong, text)
6
6
import Html.Attributes exposing (class , classList )
7
7
import Json.Decode as Decode exposing (string )
8
8
import Json.Decode.Pipeline exposing (optional , required )
9
- import Lib.HttpApi as HttpApi
9
+ import Lib.HttpApi as HttpApi exposing ( HttpResult )
10
10
import RemoteData exposing (RemoteData (..) , WebData )
11
11
import Set exposing (Set )
12
12
import UI
@@ -105,9 +105,13 @@ type Msg
105
105
| FetchAllNotificationsFinished ( WebData PaginatedNotifications )
106
106
| ToggleSelection Notification
107
107
| MarkSelectionAsUnread
108
+ | MarkNotificationsAsUnreadFinished ( HttpResult () )
108
109
| MarkSelectionAsRead
110
+ | MarkNotificationsAsReadFinished ( HttpResult () )
109
111
| ArchiveSelection
112
+ | MarkNotificationsAsArchivedFinished ( HttpResult () )
110
113
| UnarchiveSelection
114
+ | MarkNotificationsAsUnarchivedFinished ( HttpResult () )
111
115
112
116
113
117
update : AppContext -> NotificationsRoute -> Account a -> Msg -> Model -> ( Model , Cmd Msg )
@@ -233,24 +237,50 @@ fetchNotifications_ appContext account status paginationCursorParam =
233
237
|> HttpApi . perform appContext. api
234
238
235
239
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
254
284
255
285
256
286
0 commit comments