Skip to content

Commit

Permalink
Extract reset functions
Browse files Browse the repository at this point in the history
  • Loading branch information
CrisTofani authored Apr 6, 2022
2 parents 7398f2c + d249e3a commit 6b8ab1a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,20 @@ public RNZendeskChat(ReactApplicationContext reactContext) {
}

@ReactMethod
public void reset() {
log.delete(0, log.length());
public void resetCustomFields() {
customFields.clear();
}

@ReactMethod
public void resetTags() {
tags.clear();
}

@ReactMethod
public void resetLog() {
log.delete(0, log.length());
}

@Override
public String getName() {
return "RNZendeskChat";
Expand Down
10 changes: 8 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ declare module 'io-react-native-zendesk' {
// add a new tag to the ticket
export function addTicketTag(tag: string)

// remove log data and custom fields
export function reset(): void;
// remove custom fields
export function resetCustomFields(): void;

// remove tags
export function resetTags(): void;

// remove log data
export function resetLog(): void;

// iOS only - close the current zendesk view (ticket creation, tickets list) if any
export function dismiss(): void;
Expand Down
10 changes: 8 additions & 2 deletions ios/RNZendeskChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,18 @@ - (void)executeOnMainThread:(void (^)(void))block
#define MAX_TAGS_LENGTH 100
#endif

RCT_EXPORT_METHOD(reset) {
RCT_EXPORT_METHOD(resetCustomFields) {
[self initGlobals];
[mutableLog setString:@""];
[customFields removeAllObjects];
}
RCT_EXPORT_METHOD(resetTags) {
[self initGlobals];
[tags removeAllObjects];
}
RCT_EXPORT_METHOD(resetLog) {
[self initGlobals];
[mutableLog setString:@""];
}

// dismiss the current controller shown, if any
RCT_EXPORT_METHOD(dismiss) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "io-react-native-zendesk",
"version": "0.3.20",
"version": "0.3.21",
"description": "React native wrapper for Zendesk Unified SDK",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 6b8ab1a

Please sign in to comment.