Skip to content

Commit

Permalink
export setCanSendMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Nov 27, 2023
1 parent 9093191 commit 471c555
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/chat-headless/docs/chat-headless.chatheadless.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ChatHeadless
| [initSessionStorage()](./chat-headless.chatheadless.initsessionstorage.md) | Loads the [ConversationState](./chat-headless.conversationstate.md) from session storage, if present, and adds a listener to keep the conversation state in sync with the stored state |
| [report(eventPayload)](./chat-headless.chatheadless.report.md) | Send Chat related analytics event to Yext Analytics API. |
| [restartConversation()](./chat-headless.chatheadless.restartconversation.md) | Resets all fields within [ConversationState](./chat-headless.conversationstate.md) |
| [setCanSendMessage(canSendMessage)](./chat-headless.chatheadless.setcansendmessage.md) | Sets [ConversationState.canSendMessage](./chat-headless.conversationstate.cansendmessage.md) to the specified state |
| [setChatLoadingStatus(isLoading)](./chat-headless.chatheadless.setchatloadingstatus.md) | Sets [ConversationState.isLoading](./chat-headless.conversationstate.isloading.md) to the specified loading state |
| [setContext(context)](./chat-headless.chatheadless.setcontext.md) | Sets [MetaState.context](./chat-headless.metastate.context.md) to the specified context. |
| [setMessageNotes(notes)](./chat-headless.chatheadless.setmessagenotes.md) | Sets [ConversationState.notes](./chat-headless.conversationstate.notes.md) to the specified notes |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@yext/chat-headless](./chat-headless.md) &gt; [ChatHeadless](./chat-headless.chatheadless.md) &gt; [setCanSendMessage](./chat-headless.chatheadless.setcansendmessage.md)

## ChatHeadless.setCanSendMessage() method

Sets [ConversationState.canSendMessage](./chat-headless.conversationstate.cansendmessage.md) to the specified state

**Signature:**

```typescript
setCanSendMessage(canSendMessage: boolean): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| canSendMessage | boolean | the state to set |

**Returns:**

void

1 change: 1 addition & 0 deletions packages/chat-headless/etc/chat-headless.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface ChatHeadless {
initSessionStorage(): void;
report(eventPayload: Omit<ChatEventPayLoad, "chat"> & DeepPartial<Pick<ChatEventPayLoad, "chat">>): Promise<void>;
restartConversation(): void;
setCanSendMessage(canSendMessage: boolean): void;
setChatLoadingStatus(isLoading: boolean): void;
setContext(context: unknown): void;
setMessageNotes(notes: MessageNotes): void;
Expand Down
2 changes: 1 addition & 1 deletion packages/chat-headless/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/chat-headless",
"version": "0.7.1",
"version": "0.7.2",
"description": "A library for powering UI components for Yext Chat integrations",
"main": "./dist/commonjs/src/index.js",
"module": "./dist/esm/src/index.mjs",
Expand Down
15 changes: 4 additions & 11 deletions packages/chat-headless/src/ChatHeadlessImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export class ChatHeadlessImpl implements ChatHeadless {
setChatLoadingStatus(isLoading: boolean) {
this.stateManager.dispatch(setIsLoading(isLoading));
}

setCanSendMessage(canSendMessage: boolean) {
this.stateManager.dispatch(setCanSendMessage(canSendMessage));
}

/**
* Sets {@link ConversationState.conversationId} to the specified id
Expand All @@ -182,17 +186,6 @@ export class ChatHeadlessImpl implements ChatHeadless {
this.stateManager.dispatch(setConversationId(id));
}

/**
* Sets {@link ConversationState.canSendMessage} to the specified state
*
* @internal
*
* @param canSendMessage - the state to set
*/
private setCanSendMessage(canSendMessage: boolean) {
this.stateManager.dispatch(setCanSendMessage(canSendMessage));
}

restartConversation() {
this.setConversationId(undefined);
this.setChatLoadingStatus(false);
Expand Down
8 changes: 8 additions & 0 deletions packages/chat-headless/src/models/ChatHeadless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export interface ChatHeadless {
* @param isLoading - the loading state to set
*/
setChatLoadingStatus(isLoading: boolean): void;
/**
* Sets {@link ConversationState.canSendMessage} to the specified state
*
* @public
*
* @param canSendMessage - the state to set
*/
setCanSendMessage(canSendMessage: boolean): void;
/**
* Adds additional client SDKs to the base event payload for Yext Analytics API.
*
Expand Down

0 comments on commit 471c555

Please sign in to comment.