Skip to content

Commit

Permalink
feat(open/close): adds isOpen, open and close methods
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondsanity committed Oct 29, 2019
1 parent 8d4f736 commit 2e91efa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-freshchat",
"version": "0.1.0",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "https://github.com/beyondsanity/ngx-freshchat"
Expand Down
2 changes: 1 addition & 1 deletion projects/ngx-freshchat-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-freshchat",
"version": "0.1.0",
"version": "0.1.1",
"peerDependencies": {
"@angular/common": "^6.0.0-rc.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
"@angular/core": "^6.0.0-rc.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
Expand Down
30 changes: 30 additions & 0 deletions projects/ngx-freshchat-lib/src/lib/ngx-freshchat-lib.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import { first, flatMap } from 'rxjs/operators';
interface FCWidget {
init;
user;
isOpen;
open;
close;
track;
setTags;
setLocale;
Expand Down Expand Up @@ -127,6 +130,33 @@ export class NgxFreshChatService {
});
}

/**
* Checks whether the Freshchat Widget is open.
* @author beyondsanity
*/
isOpen(): boolean {
return this.getWidget().isOpen();
}

/**
* Opens the Freshchat Widget.
*
* @param payload Optional - parameters including channel id or name.
* The replyText parameter can be used to set up custom text in the text area of the widget.
* @author beyondsanity
*/
open(payload: { name?: string, channelId?: string, replyText?: string }): void {
this.getWidget().open(payload);
}

/**
* Closes the Freshchat Widget.
* @author beyondsanity
*/
close(): void {
this.getWidget().close();
}

/**
* Tracks an event against the current user.
* @param eventName The event name to track.
Expand Down

0 comments on commit 2e91efa

Please # to comment.