Skip to content

Commit

Permalink
v4.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitninawe-cometchat committed Jun 4, 2024
1 parent bd416f0 commit 9f07887
Show file tree
Hide file tree
Showing 161 changed files with 18,693 additions and 3,576 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## Table of contents
- [About the project](#about-the-project)
- [Built With](#built-with)
- [Prerequisites](#prerequisites)
- [Getting Started](#getting-started)
- [Dependencies](#dependencies)
- [Versioning](#versioning)
Expand All @@ -29,13 +29,12 @@
## About the project
CometChat React Native UIKit provides pre-built user interface kit that developers can use to quickly integrate a reliable & fully featured chat experience into an existing or a new mobile app.<br />

### Built With
- react: 17.0.2
- react native: 0.68.5
- Android Studio 2021.3 dolphin
- Xcode 14.1
- Android 9, API 28 and above
- iOS 12.0
### Prerequisites
- compileSdkVersion >= 33
- @react-native-community/datetimepicker
- @react-native-community/async-storage
- @cometchat/chat-sdk-react-native
- @react-native-community/clipboard

## Getting Started
To set up React Native Chat UIKit and utilize CometChat for your chat functionality, you'll need to follow these steps:
Expand All @@ -47,6 +46,7 @@ To set up React Native Chat UIKit and utilize CometChat for your chat functional

### Dependencies
To utilize the React Native Chat UIKit in your React native project, you need to include the necessary dependencies in your file. <br />
@react-native-community/datetimepicker <br/>
@react-native-community/async-storage <br/>
@cometchat/chat-sdk-react-native <br/>
@react-native-community/clipboard <br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext r
modules.add(new VideoManager(reactContext));
modules.add(new ImageManager(reactContext));
modules.add(new WebViewManager(reactContext));
modules.add(new TimeZoneCodeManager(reactContext));
return modules;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.reactnativecometchatuikit;

import android.util.Log;

import androidx.annotation.NonNull;

import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;

import java.util.TimeZone;

public class TimeZoneCodeManager extends ReactContextBaseJavaModule {
public static final String TAG = "TimeZoneCodeManager";

public TimeZoneCodeManager(ReactApplicationContext context) {
super(context);
}

@ReactMethod
public void getCurrentTimeZone(Callback callback) {
try {
// Get the current time zone ID
String timeZoneID = TimeZone.getDefault().getID();
// Invoke the callback with the time zone ID
callback.invoke(timeZoneID);
} catch (Exception e) {
// Log the exception
Log.e(TAG, "Error getting the time zone", e);
// If there's an error, you may choose to invoke the callback with null or an error message
callback.invoke((Object) null);
}
}

@NonNull
@Override
public String getName() {
return TAG;
}
}
6 changes: 6 additions & 0 deletions ios/TimeZoneCodeManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import <React/RCTBridgeModule.h>
#import <QuickLook/QuickLook.h>

@interface TimeZoneCodeManager : NSObject <RCTBridgeModule, QLPreviewControllerDataSource, QLPreviewControllerDelegate>

@end
22 changes: 22 additions & 0 deletions ios/TimeZoneCodeManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#import "TimeZoneCodeManager.h"
#import <React/RCTUtils.h>

@implementation TimeZoneCodeManager {

}

// This macro makes the module available to JavaScript
RCT_EXPORT_MODULE(TimeZoneCodeManager);

// Export your method to JavaScript using RCT_EXPORT_METHOD
RCT_EXPORT_METHOD(getCurrentTimeZone:(RCTResponseSenderBlock)callback) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Get the time zone string
NSString *timeZone = [[NSTimeZone localTimeZone] name];

// Call the callback block with the time zone string
callback(@[timeZone]);
});
}

@end
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cometchat/chat-uikit-react-native",
"version": "4.1.4",
"version": "4.2.0",
"description": "CometChat React Native UI Kit is a collection of custom UI Components designed to build text , chat and calling features in your application. The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly",
"main": "src/index",
"module": "src/index",
Expand Down Expand Up @@ -76,7 +76,8 @@
"peerDependencies": {
"react": "*",
"react-native": "*",
"@cometchat/chat-sdk-react-native": "*"
"@cometchat/chat-sdk-react-native": "*",
"@react-native-community/datetimepicker":"*"
},
"jest": {
"preset": "react-native",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ export class AIConversationStarterDecorator extends DataSourceDecorator {
onCardMessageReceived: (cardMessage) => {
this.closeIfMessageReceived(cardMessage)
},
onSchedulerMessageReceived: (schedulerMessage) => {
this.closeIfMessageReceived(schedulerMessage)
},
onCustomInteractiveMessageReceived: (customInteractiveMessage) => {
this.closeIfMessageReceived(customInteractiveMessage)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ export class AIConversationSummaryDecorator extends DataSourceDecorator {
onCardMessageReceived: (cardMessage) => {
this.closeIfMessageReceived(cardMessage)
},
onSchedulerMessageReceived: (schedulerMessage) => {
this.closeIfMessageReceived(schedulerMessage)
},
onCustomInteractiveMessageReceived: (customInteractiveMessage) => {
this.closeIfMessageReceived(customInteractiveMessage)
}
Expand Down
3 changes: 3 additions & 0 deletions src/AI/AISmartReplies/AISmartRepliesDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ export class AISmartRepliesExtensionDecorator extends DataSourceDecorator {
onCardMessageReceived: (cardMessage) => {
this.closeIfMessageReceived(cardMessage)
},
onSchedulerMessageReceived: (schedulerMessage) => {
this.closeIfMessageReceived(schedulerMessage)
},
onCustomInteractiveMessageReceived: (customInteractiveMessage) => {
this.closeIfMessageReceived(customInteractiveMessage)
}
Expand Down
6 changes: 5 additions & 1 deletion src/CometChatConversations/CometChatConversations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
let isTyping = args[1];
let newConversation = conversation
if (isTyping && newConversation?.['lastMessage']?.["typing"]) {
newConversation['lastMessage']["typing"] = args[0].receiverType === 'group' ?
newConversation['lastMessage']["typing"] = args[0]?.receiverType === 'group' ?
`${args[0].sender.name} : ${localize("IS_TYPING")}` :
localize("IS_TYPING");
} else {
Expand Down Expand Up @@ -837,6 +837,10 @@ export const CometChatConversations = (props: ConversationInterface) => {
messageEventHandler(cardMessage);
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
},
onSchedulerMessageReceived: (schedulerMessage) => {
messageEventHandler(schedulerMessage);
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
},
onCustomInteractiveMessageReceived: (customInteractiveMessage) => {
messageEventHandler(customInteractiveMessage);
!disableSoundForMessages && CometChatSoundManager.play("incomingMessage");
Expand Down
5 changes: 4 additions & 1 deletion src/CometChatMessageList/CometChatMessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,9 @@ export const CometChatMessageList = forwardRef<
onCardMessageReceived: (cardMessage) => {
newMessage(cardMessage);
},
onSchedulerMessageReceived: (schedulerMessage) => {
newMessage(schedulerMessage);
},
onCustomInteractiveMessageReceived: (customInteractiveMessage) => {
newMessage(customInteractiveMessage);
},
Expand Down Expand Up @@ -1221,7 +1224,7 @@ export const CometChatMessageList = forwardRef<

let bubbleAlignment: MessageBubbleAlignmentType = getAlignment(message);

return <TouchableOpacity onLongPress={() => showOptions ? openOptionsForMessage(message, hasTemplate) : undefined} >
return <TouchableOpacity activeOpacity={1} onLongPress={() => showOptions ? openOptionsForMessage(message, hasTemplate) : undefined} >
<CometChatMessageBubble
id={`${message.getId()}`}
LeadingView={() => !isThreaded && getLeadingView(message)}
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ import {
CometChatFormBubbleInterface,
CometChatCardBubble,
CometChatCardBubbleInterface,
CometChatSchedulerBubble,
CometChatSchedulerBubbleInterface,
APIAction,
ActionEntity,
BaseInputElement,
Expand All @@ -133,6 +135,7 @@ import {
DropdownElement,
ElementEntity,
FormMessage,
SchedulerMessage,
LabelElement,
OptionElement,
RadioButtonElement,
Expand Down Expand Up @@ -614,6 +617,8 @@ export {
CometChatFormBubbleInterface,
CometChatCardBubble,
CometChatCardBubbleInterface,
CometChatSchedulerBubble,
CometChatSchedulerBubbleInterface,
APIAction,
ActionEntity,
BaseInputElement,
Expand All @@ -626,6 +631,7 @@ export {
DropdownElement,
ElementEntity,
FormMessage,
SchedulerMessage,
LabelElement,
OptionElement,
RadioButtonElement,
Expand Down
33 changes: 32 additions & 1 deletion src/shared/CometChatUiKit/CometChatUIKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { AIExtensionDataSource } from "../../AI/AIExtensionDataSource";
import { AISmartRepliesExtension } from "../../AI/AISmartReplies/AISmartReplies";
import { AIConversationSummaryExtension } from "../../AI/AIConversationSummary/AIConversationSummaryExtension";
import { AIAssistBotExtension } from "../../AI/AIAssistBot/AIAssistBotExtension";
import { SchedulerMessage } from "../modals/InteractiveData/InteractiveMessage";

export class CometChatUIKit {
static uiKitSettings: UIKitSettings;
Expand All @@ -36,7 +37,6 @@ export class CometChatUIKit {
CometChatUIKit.uiKitSettings = {
...uiKitSettings
};
console.log(uiKitSettings?.overrideAdminHost, uiKitSettings.overrideClientHost)
var appSetting = new CometChat.AppSettingsBuilder()
.subscribePresenceForAllUsers()
.autoEstablishSocketConnection(uiKitSettings.autoEstablishSocketConnection)
Expand Down Expand Up @@ -245,6 +245,37 @@ export class CometChatUIKit {
});
}


/**
* Sends a Scheduler message and emits events based on the message status.
* @param message - The Scheduler message to be sent.
* @param disableLocalEvents - A boolean indicating whether to disable local events or not. Default value is false.
*/
static sendSchedulerMessage(message: SchedulerMessage, disableLocalEvents: boolean = false): Promise<CometChat.TextMessage | CometChat.BaseMessage> {
return new Promise((resolve, reject) => {
if (!disableLocalEvents) {
CometChatUIKitHelper.onMessageSent(message, messageStatus.inprogress);
}

CometChat.sendInteractiveMessage(message)
.then((message: CometChat.BaseMessage) => {
console.log("message sent successfully", message.getSentAt())
if (!disableLocalEvents) {
CometChatUIKitHelper.onMessageSent(message, messageStatus.success);
}
resolve(message);
})
.catch((error: CometChat.CometChatException) => {
console.log("error while sending message", { error })
message.setMetadata({ error });
// if (!disableLocalEvents) {
// CometChatUIKitHelper.onMessageSent(message, messageStatus.error);
// }
reject(error);
});
});
}

/**
* Sends a FormMessage message and emits events based on the message status.
* @param message - The FormMessage message to be sent.
Expand Down
Binary file added src/shared/assets/images/BackArrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/assets/images/calendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/assets/images/clock-alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/assets/images/clock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/assets/images/earth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/assets/images/empty-slot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/shared/assets/images/forwardArrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/shared/assets/images/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import BACK from './Back.png';
import EARTH from './earth.png';
import CALENDAR from './calendar.png';
import CLOCK from './clock.png';
import BACK_ARROW from './BackArrow.png';
import FORWARD_ARROW from './forwardArrow.png';
import CHECK_MARK from './checkmark.png'
import WAITING from './sending.png';
import GREY_TICK from './grey-tick-icon.png';
import GREY_DOUBLE_TICK from './grey-double-tick-icon.png';
import BLUE_DOUBLE_TICK from './blue-double-tick-icon.png';
import ERROR_TICK from './error.png';
import CLOCK_ALERT from './empty-slot.png';

export const ICONS = {
BACK,
CALENDAR,
CLOCK,
CLOCK_ALERT,
EARTH,
BACK_ARROW,
FORWARD_ARROW,
CHECK_MARK,
WAITING,
GREY_TICK,
Expand Down
2 changes: 2 additions & 0 deletions src/shared/constants/UIKitConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export const MessageTypeConstants = {
document: "extension_document",
whiteboard: "extension_whiteboard",
meeting: "meeting",
scheduler: "scheduler",
location: "location",
groupActions: "groupActions",
form: "form",
Expand Down Expand Up @@ -356,6 +357,7 @@ export enum ElementType {
text = "textInput",
dropdown = "dropdown",
checkbox = "checkbox",
dateTime = "dateTime",
radio = "radio",
button = "button",
singleSelect = "singleSelect",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ export class CometChatUIEventHandler {
case listener._eventListener.onCardMessageReceived?.name:
listener._eventListener.onCardMessageReceived(param);
break
case listener._eventListener.onSchedulerMessageReceived?.name:
listener._eventListener.onSchedulerMessageReceived(param);
break
case listener._eventListener.onCustomInteractiveMessageReceived?.name:
listener._eventListener.onCustomInteractiveMessageReceived(param);
break
Expand Down
4 changes: 4 additions & 0 deletions src/shared/events/CometChatUIEventHandler/Listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type MessageUIEvents = {
onTransientMessageReceived?: Function,
onFormMessageReceived?: Function,
onCardMessageReceived?: Function,
onSchedulerMessageReceived?: Function,
onCustomInteractiveMessageReceived?: Function,
onInteractionGoalCompleted?: Function,

Expand All @@ -54,6 +55,7 @@ export class MessageUIEventListener {
onTransientMessageReceived?: Function = undefined;
onFormMessageReceived?: Function = undefined;
onCardMessageReceived?: Function = undefined;
onSchedulerMessageReceived?: Function = undefined;
onCustomInteractiveMessageReceived?: Function = undefined;
onInteractionGoalCompleted?: Function = undefined;
// ccMessageForwarded?:Function = undefined;
Expand All @@ -78,6 +80,7 @@ export class MessageUIEventListener {
onTransientMessageReceived,
onFormMessageReceived,
onCardMessageReceived,
onSchedulerMessageReceived,
onCustomInteractiveMessageReceived,
onInteractionGoalCompleted,
// ccMessageForwarded,
Expand All @@ -103,6 +106,7 @@ export class MessageUIEventListener {
if (!isFalsy(onTransientMessageReceived)) this.onTransientMessageReceived = onTransientMessageReceived;
if (!isFalsy(onFormMessageReceived)) this.onFormMessageReceived = onFormMessageReceived;
if (!isFalsy(onCardMessageReceived)) this.onCardMessageReceived = onCardMessageReceived;
if (!isFalsy(onSchedulerMessageReceived)) this.onSchedulerMessageReceived = onSchedulerMessageReceived;
if (!isFalsy(onCustomInteractiveMessageReceived)) this.onCustomInteractiveMessageReceived = onCustomInteractiveMessageReceived;
if (!isFalsy(onInteractionGoalCompleted)) this.onInteractionGoalCompleted = onInteractionGoalCompleted;

Expand Down
3 changes: 3 additions & 0 deletions src/shared/events/ListenerInitializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export class ListenerInitializer {
case MessageTypeConstants.card:
CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCardMessageReceived, message);
break;
case MessageTypeConstants.scheduler:
CometChatUIEventHandler.emitMessageEvent(MessageEvents.onSchedulerMessageReceived, message);
break;
default:
CometChatUIEventHandler.emitMessageEvent(MessageEvents.onCustomInteractiveMessageReceived, message);
break;
Expand Down
1 change: 1 addition & 0 deletions src/shared/events/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum MessageEvents {
onTransientMessageReceived = "onTransientMessageReceived",
onFormMessageReceived = "onFormMessageReceived",
onCardMessageReceived = "onCardMessageReceived",
onSchedulerMessageReceived = "onSchedulerMessageReceived",
onInteractionGoalCompleted = "onInteractionGoalCompleted",
onCustomInteractiveMessageReceived = "onCustomInteractiveMessageReceived",
}
Loading

0 comments on commit 9f07887

Please sign in to comment.