Skip to content

Commit

Permalink
Merge pull request #19 from manner/feat-message-delay
Browse files Browse the repository at this point in the history
Allow customization of messageDelay
  • Loading branch information
awran5 committed Dec 31, 2022
2 parents 0ae241b + 9d4d44b commit 4dee951
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default function App() {
| `statusMessage` | String | Optional | Text below the account username | `Typically replies within 1 hour` |
| `chatMessage` | String | Optional | Text inside the chat box. | `Hello there! 🤝 \nHow can we help?` |
| `placeholder` | String | Optional | Input placeholder. | `Type a message..` |
| `messageDelay` | Number | Optional | Time delay after which the chatMessage is displayed (in seconds). | `2` |
| `darkMode` | Boolean | Optional | Dark style. | `false` |
| `allowClickAway` | Boolean | Optional | Closes the chat box when user clicks outside | `false` |
| `allowEsc` | Boolean | Optional | Closes the chat box when `Escape` key is pressed | `false` |
Expand Down
7 changes: 6 additions & 1 deletion src/Components/FloatingWhatsapp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ export interface FloatingWhatsAppProps {
/** Input placeholder */
placeholder?: string

/** Time delay after which the chatMessage is displayed (in seconds) */
messageDelay?: number

/** Allow notifications (Disabled after user opens the chat box) */
notification?: boolean
/** Time delay between notifications in seconds */
Expand Down Expand Up @@ -85,6 +88,8 @@ export function FloatingWhatsApp({
chatMessage = 'Hello there! 🤝 \nHow can we help?',
placeholder = 'Type a message..',

messageDelay = 2,

allowClickAway = false,
allowEsc = false,

Expand Down Expand Up @@ -158,7 +163,7 @@ export function FloatingWhatsApp({

clearInterval(notificationInterval.current)
dispatch({ type: 'open' })
setTimeout(() => dispatch({ type: 'delay' }), 2000)
setTimeout(() => dispatch({ type: 'delay' }), messageDelay * 1000)
if (onClick) onClick(event)
},
[isOpen, onClick]
Expand Down

0 comments on commit 4dee951

Please sign in to comment.