Skip to content

Commit

Permalink
Merge pull request #509 from novuhq/DVRL-177
Browse files Browse the repository at this point in the history
remove multiple notifications hook method docs
  • Loading branch information
jainpawan21 committed Feb 8, 2024
2 parents b025282 + d5d117c commit 4d1e287
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 36 deletions.
2 changes: 1 addition & 1 deletion mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -643,5 +643,5 @@
"domain": "docs.novu.co"
}
},
"versions": ["v0.22.0", "v0.21.0", "v0.20.0", "v0.19.0", "v0.18.0"]
"versions": ["v0.23.0","v0.22.0", "v0.21.0", "v0.20.0", "v0.19.0", "v0.18.0"]
}
106 changes: 71 additions & 35 deletions notification-center/client/headless/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ interface IUpdateUserPreferences {

## markNotificationsAsRead

mark a single or multiple notifications as read using the message id.
Mark a single or multiple notifications as read using the message id.

```typescript
headlessService.markNotificationsAsRead({
Expand Down Expand Up @@ -323,7 +323,7 @@ interface IMarkNotificationsAsRead {

## markNotificationsAsSeen

mark a single or multiple notifications as seen using the message id.
Mark a single or multiple notifications as seen using the message id.

```typescript
headlessService.markNotificationsAsSeen({
Expand Down Expand Up @@ -356,7 +356,7 @@ interface IMarkNotificationsAsSeen {

## markNotificationsAs

mark a single or multiple notifications using the message id.
Mark a single or multiple notifications using the message id.

```typescript
headlessService.markNotificationsAs({
Expand Down Expand Up @@ -393,7 +393,7 @@ interface IMarkNotificationsAs {

## removeNotification

removes a single notification using the message id.
Removes a single notification using the message id.

```typescript
headlessService.removeNotification({
Expand Down Expand Up @@ -425,9 +425,75 @@ interface IRemoveNotification {
}
```

## removeNotifications

<Note>This method is available from version 0.23.1</Note>

Removes multiple notifications using array of message ids (limit of 100).

```typescript
headlessService.removeNotifications({
listener: (
result: UpdateResult<IMessage, unknown, { messageId: string }>
) => {
console.log(result);
},
onSuccess: (message: IMessage) => {
console.log(message);
},
onError: (error: unknown) => {
console.error(error);
},
messageIds: ["message_id_1", "message_id_2" ],
});
```

### method args interface

```typescript
interface IRemoveNotification {
messageIds: string[];
listener: (
result: UpdateResult<IMessage, unknown, { messageId: string }>
) => void;
onSuccess?: (message: IMessage) => void;
onError?: (error: unknown) => void;
}
```

## removeAllNotifications

Removes all notifications. Can be used to remove all notifications of a feed by passing the `feedId`

```typescript
headlessService.removeAllNotifications({
listener: (result: UpdateResult<void, unknown, undefined>) => {
console.log(result);
},
onSuccess: () => {
console.log("success");
},
onError: (error: unknown) => {
console.error(error);
},
feedId: "feedOne",
});
```

### method args interface

```typescript
interface IRemoveAllNotifications {
feedId?: string;
listener: (result: UpdateResult<void, unknown, undefined>) => void;
onSuccess?: () => void;
onError?: (error: unknown) => void;
}
```

## updateAction

updates the action button for the notifications.
Updates the action button for the notifications.

```typescript
headlessService.updateAction({
Expand Down Expand Up @@ -527,36 +593,6 @@ interface IMarkAllMessagesAsSeen {
}
```

## removeAllNotifications

Removes all notifications. Can be used to remove all notifications of a feed by passing the `feedId`

```typescript
headlessService.removeAllNotifications({
listener: (result: UpdateResult<void, unknown, undefined>) => {
console.log(result);
},
onSuccess: () => {
console.log("success");
},
onError: (error: unknown) => {
console.error(error);
},
feedId: "feedOne",
});
```

### method args interface

```typescript
interface IRemoveAllNotifications {
feedId?: string;
listener: (result: UpdateResult<void, unknown, undefined>) => void;
onSuccess?: () => void;
onError?: (error: unknown) => void;
}
```

## Types and Interfaces

```typescript
Expand Down
43 changes: 43 additions & 0 deletions notification-center/client/react/api-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,49 @@ interface IUseRemoveNotificationResult {
}
```

### useRemoveNotifications

<Note>This hook is available from version 0.23.1</Note>

`useRemoveNotification` hook allows you to remove multiple messages with a limit of 100 messageIds in single call.

```typescript
const onSuccess = (data: IMessage) => {};

const onError = (error: Error) => {};

const { removeNotifications, isLoading, isError, error } = useRemoveNotification({
onSuccess,
onError,
});
```

`useRemoveNotifications` hook args interface

```typescript
interface IUseRemoveNotificationArgs {
onSuccess?: (data: IMessage) => void;
onError?: (error: Error) => void;
// ... many more from the react-query useMutation hook
}
```

`useRemoveNotifications` hook return interface

```typescript
interface IRemoveNotificationsVariables {
messageIds: string[];
}

interface IUseRemoveNotificationResult {
removeNotifications: (args: IRemoveNotificationsVariables) => void;
isLoading: boolean;
isError: boolean;
error?: Error;
// ... many more from the react-query useMutation hook result
}
```

### useRemoveAllNotifications

`useRemoveAllNotifications` hook allows you to remove all messages of all feeds. feedId can be used as param to delete only specific feed's messages.
Expand Down

0 comments on commit 4d1e287

Please sign in to comment.