@vserifsaglam/chat-react-client 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,8 +6,8 @@ export declare function useMessageManagement(selectedConversationId: string): {
6
6
  fileLoading: boolean;
7
7
  uploadProgress: number;
8
8
  uploadFile: (file: File) => Promise<import("..").FileUploadResponse | null>;
9
- handleSendMessage: (content: string, receiver: SenderReceiverUser) => Promise<any>;
10
- handleSendFileMessage: (content: string, fileId: number, receiver: SenderReceiverUser, filename?: string | undefined, url?: string | undefined) => Promise<boolean | undefined>;
9
+ handleSendMessage: (content: string, receiver: SenderReceiverUser, isAppointment?: boolean | undefined) => Promise<any>;
10
+ handleSendFileMessage: (content: string, fileId: number, receiver: SenderReceiverUser, filename?: string | undefined, url?: string | undefined, isAppointment?: boolean | undefined) => Promise<boolean | undefined>;
11
11
  deleteMessage: (messageId: number) => Promise<import("..").DeleteMessageResponse | null>;
12
12
  updateMessage: (messageId: number, update: import("..").UpdateMessageRequest) => Promise<import("..").UpdateMessageResponse | null>;
13
13
  getMessages: (conversationId?: any, page?: any, pageSize?: any) => Promise<import("..").MessagesResponse | null>;
package/dist/index.js CHANGED
@@ -191,6 +191,26 @@ function _finallyRethrows(body, finalizer) {
191
191
  return finalizer(false, result);
192
192
  }
193
193
 
194
+ function _extends() {
195
+ return _extends = Object.assign ? Object.assign.bind() : function (n) {
196
+ for (var e = 1; e < arguments.length; e++) {
197
+ var t = arguments[e];
198
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
199
+ }
200
+ return n;
201
+ }, _extends.apply(null, arguments);
202
+ }
203
+ function _objectWithoutPropertiesLoose(r, e) {
204
+ if (null == r) return {};
205
+ var t = {};
206
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
207
+ if (-1 !== e.indexOf(n)) continue;
208
+ t[n] = r[n];
209
+ }
210
+ return t;
211
+ }
212
+
213
+ var _excluded = ["isAppointment"];
194
214
  var ChatApi = /*#__PURE__*/function () {
195
215
  function ChatApi(config) {
196
216
  this.client = axios.create({
@@ -326,7 +346,15 @@ var ChatApi = /*#__PURE__*/function () {
326
346
  _proto.sendMessage = function sendMessage(message) {
327
347
  try {
328
348
  var _this1 = this;
329
- return Promise.resolve(_this1.client.post('/api/messages/send-message', message)).then(function (response) {
349
+ var config = {};
350
+ if (message.isAppointment) {
351
+ config.headers = {
352
+ 'x-disable-limit': true
353
+ };
354
+ }
355
+ var isAppointment = message.isAppointment,
356
+ messageToSend = _objectWithoutPropertiesLoose(message, _excluded);
357
+ return Promise.resolve(_this1.client.post('/api/messages/send-message', messageToSend, config)).then(function (response) {
330
358
  return response.data;
331
359
  });
332
360
  } catch (e) {
@@ -479,16 +507,6 @@ var ChatApi = /*#__PURE__*/function () {
479
507
  return ChatApi;
480
508
  }();
481
509
 
482
- function _extends() {
483
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
484
- for (var e = 1; e < arguments.length; e++) {
485
- var t = arguments[e];
486
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
487
- }
488
- return n;
489
- }, _extends.apply(null, arguments);
490
- }
491
-
492
510
  (function (ConnectionType) {
493
511
  ConnectionType["WebSocket"] = "websocket";
494
512
  ConnectionType["LongPolling"] = "longpolling";
@@ -2815,7 +2833,7 @@ function useMessageManagement(selectedConversationId) {
2815
2833
  return Promise.reject(e);
2816
2834
  }
2817
2835
  }, [messagesLoading, hasMore, getMessages, page, selectedConversationId]);
2818
- var handleSendMessage = React.useCallback(function (content, receiver) {
2836
+ var handleSendMessage = React.useCallback(function (content, receiver, isAppointment) {
2819
2837
  try {
2820
2838
  if (!content.trim() || !selectedConversationId || !profile) return Promise.resolve();
2821
2839
  var tempMessageId = "temp-" + Date.now();
@@ -2840,7 +2858,8 @@ function useMessageManagement(selectedConversationId) {
2840
2858
  return Promise.resolve(sendMessage({
2841
2859
  receiver_client_id: receiver.id,
2842
2860
  content: content,
2843
- conversation_uid: selectedConversationId
2861
+ conversation_uid: selectedConversationId,
2862
+ isAppointment: isAppointment
2844
2863
  })).then(function (success) {
2845
2864
  if (!success) {
2846
2865
  setMessages(function (prevMessages) {
@@ -2885,7 +2904,7 @@ function useMessageManagement(selectedConversationId) {
2885
2904
  return Promise.reject(e);
2886
2905
  }
2887
2906
  }, [sendMessage, selectedConversationId, profile === null || profile === void 0 ? void 0 : profile.id, setMessages]);
2888
- var handleSendFileMessage = React.useCallback(function (content, fileId, receiver, filename, url) {
2907
+ var handleSendFileMessage = React.useCallback(function (content, fileId, receiver, filename, url, isAppointment) {
2889
2908
  try {
2890
2909
  if (!selectedConversationId) return Promise.resolve();
2891
2910
  var tempMessageId = "temp-file-" + Date.now();
@@ -2915,7 +2934,8 @@ function useMessageManagement(selectedConversationId) {
2915
2934
  receiver_client_id: receiver.id,
2916
2935
  content: content,
2917
2936
  attachments: [fileId],
2918
- conversation_uid: selectedConversationId
2937
+ conversation_uid: selectedConversationId,
2938
+ isAppointment: isAppointment
2919
2939
  })).then(function (success) {
2920
2940
  if (success) {
2921
2941
  setMessages(function (prevMessages) {