corp-chat-library-antd-react-socket 1.2.23 → 1.2.24

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.
package/README.md CHANGED
@@ -43,12 +43,13 @@ export interface HttpParams {
43
43
  BFF_PORT: number;
44
44
  }
45
45
 
46
- export interface FetchParams {
47
- fetchChatsListPath: string;
48
- fetchChatMessagesPath: string;
49
- sendSmsPath: string;
50
- markMessagesAsReadPath: string;
51
- }
46
+ export interface FetchParams {
47
+ fetchChatsListPath: string;
48
+ fetchChatMessagesPath: string;
49
+ fetchMessageContextPath?: string;
50
+ sendSmsPath: string;
51
+ markMessagesAsReadPath: string;
52
+ }
52
53
 
53
54
  export interface SocketSubscribe {
54
55
  subscribeToChat: string;
@@ -172,10 +173,11 @@ export interface fetchChatMessagesPathResponse {
172
173
  "content": {
173
174
  "messages": [
174
175
  {
175
- "id": 626,
176
- "from_id": 584,
177
- "answer": null,
178
- "text": "text",
176
+ "id": 626,
177
+ "from_id": 584,
178
+ "answer": null,
179
+ "answer_message": null,
180
+ "text": "text",
179
181
  "files": [
180
182
  {
181
183
  "id": 23,
@@ -195,10 +197,37 @@ export interface fetchChatMessagesPathResponse {
195
197
  },
196
198
  "message": "OK!"
197
199
  }
198
- ```
199
- ---
200
-
201
- ### "sendSmsPath"
200
+ ```
201
+ ---
202
+
203
+ ### "fetchMessageContextPath"
204
+ When a reply points to a message that is not loaded in the current chat, the chat will load a pack of messages around that target message and then scroll to it.\
205
+ Request URL:
206
+ ```ts
207
+ `${fetchMessageContextPath}/${chatId}/${messageId}`
208
+ ```
209
+
210
+ payload:
211
+ ```ts
212
+ const payload = {
213
+ "_token": "006GmuwH1vmrE8OdOIax4ySEd3FDreDD1u78t5ll"
214
+ }
215
+ ```
216
+
217
+ expected response format:
218
+ ```ts
219
+ export interface fetchMessageContextPathResponse {
220
+ "content": {
221
+ "messages": ChatMessage[],
222
+ "who": "Name Surname",
223
+ "total": 19
224
+ },
225
+ "message": "OK!"
226
+ }
227
+ ```
228
+ ---
229
+
230
+ ### "sendSmsPath"
202
231
  When you scroll up the chat, a pack of older messages will be loaded.\
203
232
  formData payload:
204
233
  ```
@@ -346,11 +375,12 @@ export interface To {
346
375
  ```
347
376
  Message format for the opened chat:
348
377
  ```ts
349
- export interface ChatMessage {
350
- id: number,
351
- from_id: number,
352
- answer: number | null,
353
- text: string,
378
+ export interface ChatMessage {
379
+ id: number,
380
+ from_id: number,
381
+ answer: number | null,
382
+ answer_message?: ChatMessage | null,
383
+ text: string,
354
384
  files: File[],
355
385
  status: boolean,
356
386
  created_at: number,
@@ -14,6 +14,7 @@ interface ChatSocketContextType {
14
14
  loadingSendSms: boolean;
15
15
  fetchChatsList: (search: string | null) => void;
16
16
  fetchChatMessages: (chatId: number, lastMsg: number | null) => void;
17
+ fetchMessageContext: (chatId: number, messageId: number) => Promise<boolean>;
17
18
  sendSms: ({ to, text, files, answer, timestamp, from_id }: toSendSms) => void;
18
19
  markMessagesAsRead: (messageIds: (number | undefined)[]) => void;
19
20
  setSubscribeToChat: (search: string | null) => void;
@@ -31,6 +32,7 @@ interface ChatSocketContextType {
31
32
  PROD_AXIOS_INSTANCE: AxiosInstance | null;
32
33
  setFetchChatsListPath: (path: string | null) => void;
33
34
  setFetchChatMessagesPath: (path: string | null) => void;
35
+ setFetchMessageContextPath: (path: string | null) => void;
34
36
  setSendSmsPath: (path: string | null) => void;
35
37
  setMarkMessagesAsReadPath: (path: string | null) => void;
36
38
  init: boolean;
@@ -17,6 +17,7 @@ export interface HttpParams {
17
17
  export interface FetchParams {
18
18
  fetchChatsListPath: string;
19
19
  fetchChatMessagesPath: string;
20
+ fetchMessageContextPath?: string;
20
21
  sendSmsPath: string;
21
22
  markMessagesAsReadPath: string;
22
23
  }
@@ -126,6 +127,7 @@ export interface ChatMessage {
126
127
  id: number;
127
128
  from_id: number;
128
129
  answer: number | null;
130
+ answer_message?: ChatMessage | null;
129
131
  text: string;
130
132
  files: File[];
131
133
  status: boolean;
@@ -145,6 +147,7 @@ export interface Normalized {
145
147
  fromId: number;
146
148
  id: number;
147
149
  answer: number | null;
150
+ answerMessage?: ChatMessage | null;
148
151
  text: string;
149
152
  files: File[];
150
153
  timestamp: number;