@daeryun/dr_components 0.9.56 → 0.9.58

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.
Files changed (36) hide show
  1. package/dist/components/Daeryuntalk/ChatConversation.jsx +65 -10
  2. package/dist/components/Daeryuntalk/ChatConversation.tsx +65 -11
  3. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.jsx +2 -2
  4. package/dist/components/Daeryuntalk/ChatItem/ChatWrapper.tsx +2 -2
  5. package/dist/components/Daeryuntalk/ChatMessage.jsx +1 -1
  6. package/dist/components/Daeryuntalk/ChatMessage.tsx +1 -1
  7. package/dist/components/Daeryuntalk/ChatWidget.jsx +2 -2
  8. package/dist/components/Daeryuntalk/ChatWidget.tsx +2 -2
  9. package/dist/components/Daeryuntalk/HomeView.jsx +1 -1
  10. package/dist/components/Daeryuntalk/HomeView.tsx +1 -1
  11. package/dist/components/Daeryuntalk/Viewer/MobileViewer.jsx +2 -2
  12. package/dist/components/Daeryuntalk/Viewer/MobileViewer.tsx +2 -2
  13. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.jsx +4 -2
  14. package/dist/components/Daeryuntalk/Viewer/TbPcViewer.tsx +2 -1
  15. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.d.ts +1 -1
  16. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.js +2 -4
  17. package/dist/components/Daeryuntalk/_api/daeryuntalk/index.ts +2 -3
  18. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.d.ts +1 -1
  19. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.js +21 -20
  20. package/dist/components/Daeryuntalk/_hooks/talkprovider/useChatHandler.ts +28 -19
  21. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.js +2 -2
  22. package/dist/components/Daeryuntalk/_hooks/talkprovider/useSocketEventHandler.ts +2 -2
  23. package/dist/components/Daeryuntalk/_lib/index.d.ts +1 -1
  24. package/dist/components/Daeryuntalk/_lib/index.js +2 -2
  25. package/dist/components/Daeryuntalk/_lib/index.ts +2 -1
  26. package/dist/components/Daeryuntalk/_types/message.d.ts +1 -0
  27. package/dist/components/Daeryuntalk/_types/message.ts +3 -0
  28. package/dist/components/Daeryuntalk/index.jsx +0 -1
  29. package/dist/components/Daeryuntalk/index.tsx +0 -1
  30. package/dist/components/common/strength/index.js +1 -1
  31. package/dist/components/common/strength/index.ts +1 -1
  32. package/dist/components/page/Strength/StrengthIntro.jsx +1 -2
  33. package/dist/components/page/Strength/StrengthIntro.tsx +1 -2
  34. package/dist/styles/globals.css +13 -4
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +1 -1
@@ -1,3 +1,12 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
1
10
  import React, { useEffect, useMemo, useRef, useState } from 'react';
2
11
  import { useDaeryuntalk } from './DaeryuntalkContext';
3
12
  import ChatMessage from './ChatMessage';
@@ -12,7 +21,11 @@ import { useWindowSize } from './_hooks/useWindowSize';
12
21
  import TypingComp from './ChatItem/TypingComp';
13
22
  const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose, isHash }) => {
14
23
  var _a, _b;
15
- const { inquiryStatus, messages, isLoading, inquiryMainData, messageObject, workFlowBack, workFlowStack, chatInquiryNumber, isTyping } = useDaeryuntalk();
24
+ const { getNextMessageList, isNextPage, inquiryStatus, messages, isLoading, inquiryMainData, messageObject, workFlowBack, workFlowStack, chatInquiryNumber, isTyping } = useDaeryuntalk();
25
+ const [isFetchingPrev, setIsFetchingPrev] = useState(false);
26
+ const sortedMessages = useMemo(() => {
27
+ return (messages === null || messages === void 0 ? void 0 : messages.length) ? messages.slice().sort((a, b) => a.timestamp - b.timestamp) : [];
28
+ }, [messages]);
16
29
  const [isHovered, setIsHovered] = useState(false);
17
30
  const headerRef = useRef(null);
18
31
  const pcBottomRef = useRef(null);
@@ -21,6 +34,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
21
34
  const windowSize = useWindowSize();
22
35
  // 최초 렌더 여부 플래그
23
36
  const isInitialMount = useRef(true);
37
+ // 이후
24
38
  const messagesContainerRef = useRef(null);
25
39
  const messagesEndRef = useRef(null);
26
40
  useEffect(() => {
@@ -61,17 +75,21 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
61
75
  var _a;
62
76
  (_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: 'smooth' });
63
77
  };
64
- // 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동
78
+ // 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동 sortedMessages의 마지막 행에 type이 live일 경우만 scrollEnd 실행
65
79
  useEffect(() => {
80
+ const lastMessage = sortedMessages && sortedMessages.length > 0 && sortedMessages[sortedMessages.length - 1];
81
+ if (!lastMessage || (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.type) !== 'live')
82
+ return;
66
83
  const timeout = setTimeout(() => {
67
84
  scrollEnd();
68
85
  }, 200);
69
86
  return () => clearTimeout(timeout); // cleanup
70
- }, [messages, messageObject]);
87
+ }, [sortedMessages, messageObject]);
88
+ // 최초 진입 시 스크롤 최하단으로 이동
71
89
  useEffect(() => {
72
90
  if (!isInitialMount.current)
73
91
  return;
74
- if (messages.length === 0)
92
+ if (sortedMessages.length === 0)
75
93
  return;
76
94
  const container = messagesContainerRef.current;
77
95
  if (!container)
@@ -83,8 +101,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
83
101
  return;
84
102
  hasScrolled = true;
85
103
  requestAnimationFrame(() => {
86
- var _a;
87
- (_a = messagesEndRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView({ behavior: 'smooth' });
104
+ scrollEnd(); // 무조건 실행
88
105
  isInitialMount.current = false;
89
106
  });
90
107
  };
@@ -102,7 +119,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
102
119
  }
103
120
  };
104
121
  if (img.complete) {
105
- // 이미지가 이미 로드된 경우, 강제 reload로 안정성 확보
122
+ // 강제 로드 보장
106
123
  const newImg = new Image();
107
124
  newImg.src = img.src;
108
125
  newImg.onload = done;
@@ -113,7 +130,43 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
113
130
  img.addEventListener('error', done, { once: true });
114
131
  }
115
132
  });
116
- }, [messages, messageObject]);
133
+ // fallback 타이머로 scrollToBottom 보장 (예: 이미지 로딩 실패 시)
134
+ const fallback = setTimeout(() => {
135
+ scrollToBottom();
136
+ }, 500); // 1초 후 강제 실행
137
+ return () => clearTimeout(fallback);
138
+ }, [sortedMessages, messageObject]);
139
+ // 무한 스크롤
140
+ useEffect(() => {
141
+ const container = messagesContainerRef.current;
142
+ if (!container || !isNextPage || !chatInquiryNumber || sortedMessages.length === 0)
143
+ return;
144
+ const handleScroll = () => __awaiter(void 0, void 0, void 0, function* () {
145
+ const { scrollTop, scrollHeight, clientHeight } = container;
146
+ // 스크롤이 없더라도 무시하지 않음! → handleScroll은 무한스크롤 용도에만 사용
147
+ const scrolledPercent = (scrollTop / scrollHeight) * 100;
148
+ if (scrolledPercent < 5 && !isFetchingPrev) {
149
+ setIsFetchingPrev(true);
150
+ const prevScrollHeight = container.scrollHeight;
151
+ const oldestMessage = sortedMessages[0];
152
+ if (!(oldestMessage === null || oldestMessage === void 0 ? void 0 : oldestMessage.createdAt))
153
+ return;
154
+ try {
155
+ yield getNextMessageList(chatInquiryNumber, oldestMessage.timestamp);
156
+ requestAnimationFrame(() => {
157
+ const newScrollHeight = container.scrollHeight;
158
+ container.scrollTop = newScrollHeight - prevScrollHeight;
159
+ });
160
+ }
161
+ finally {
162
+ setIsFetchingPrev(false);
163
+ }
164
+ }
165
+ });
166
+ handleScroll();
167
+ container.addEventListener('scroll', handleScroll);
168
+ return () => container.removeEventListener('scroll', handleScroll);
169
+ }, [sortedMessages, chatInquiryNumber, isNextPage, isFetchingPrev, getNextMessageList]);
117
170
  const isNewDay = (date1, date2) => {
118
171
  return (date1.getFullYear() !== date2.getFullYear() ||
119
172
  date1.getMonth() !== date2.getMonth() ||
@@ -121,7 +174,9 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
121
174
  };
122
175
  const renderedMessages = useMemo(() => {
123
176
  const elements = [];
124
- const sortedMessages = messages && messages.length > 0 ? messages.sort((a, b) => a.timestamp - b.timestamp) : [];
177
+ if (sortedMessages.length < 1) {
178
+ return;
179
+ }
125
180
  sortedMessages.forEach((message, index) => {
126
181
  const findObject = message.workFlow &&
127
182
  (messageObject === null || messageObject === void 0 ? void 0 : messageObject.exposeObjectListYn) &&
@@ -135,7 +190,7 @@ const ChatConversation = ({ onBackClick, onChatNew, isActive, isMobile, onClose,
135
190
  });
136
191
  return elements;
137
192
  }, [
138
- messages,
193
+ sortedMessages,
139
194
  messageObject, // 둘 다 바뀌면 리렌더됨
140
195
  isMobile,
141
196
  inquiryStatus,
@@ -30,6 +30,8 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
30
30
  isHash
31
31
  }) => {
32
32
  const {
33
+ getNextMessageList,
34
+ isNextPage,
33
35
  inquiryStatus,
34
36
  messages,
35
37
  isLoading,
@@ -40,6 +42,13 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
40
42
  chatInquiryNumber,
41
43
  isTyping
42
44
  } = useDaeryuntalk();
45
+
46
+ const [isFetchingPrev, setIsFetchingPrev] = useState(false);
47
+
48
+ const sortedMessages = useMemo(() => {
49
+ return messages?.length ? messages.slice().sort((a, b) => a.timestamp - b.timestamp) : [];
50
+ }, [messages]);
51
+
43
52
  const [isHovered, setIsHovered] = useState<boolean>(false);
44
53
 
45
54
  const headerRef = useRef<HTMLDivElement | null>(null);
@@ -51,6 +60,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
51
60
 
52
61
  // 최초 렌더 여부 플래그
53
62
  const isInitialMount = useRef(true);
63
+ // 이후
54
64
  const messagesContainerRef = useRef<HTMLDivElement | null>(null);
55
65
  const messagesEndRef = useRef<HTMLDivElement>(null);
56
66
 
@@ -100,18 +110,21 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
100
110
  messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
101
111
  };
102
112
 
103
- // 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동
113
+ // 새 메시지가 도착할 때 자동으로 스크롤 최하단으로 이동 sortedMessages의 마지막 행에 type이 live일 경우만 scrollEnd 실행
104
114
  useEffect(() => {
115
+ const lastMessage = sortedMessages && sortedMessages.length > 0 && sortedMessages[sortedMessages.length - 1];
116
+ if (!lastMessage || lastMessage?.type !== 'live') return;
117
+
105
118
  const timeout = setTimeout(() => {
106
119
  scrollEnd();
107
120
  }, 200);
108
121
  return () => clearTimeout(timeout); // cleanup
109
- }, [messages, messageObject]);
122
+ }, [sortedMessages, messageObject]);
110
123
 
124
+ // 최초 진입 시 스크롤 최하단으로 이동
111
125
  useEffect(() => {
112
126
  if (!isInitialMount.current) return;
113
-
114
- if (messages.length === 0) return;
127
+ if (sortedMessages.length === 0) return;
115
128
 
116
129
  const container = messagesContainerRef.current;
117
130
  if (!container) return;
@@ -124,7 +137,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
124
137
  hasScrolled = true;
125
138
 
126
139
  requestAnimationFrame(() => {
127
- messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
140
+ scrollEnd(); // 무조건 실행
128
141
  isInitialMount.current = false;
129
142
  });
130
143
  };
@@ -146,7 +159,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
146
159
  };
147
160
 
148
161
  if (img.complete) {
149
- // 이미지가 이미 로드된 경우, 강제 reload로 안정성 확보
162
+ // 강제 로드 보장
150
163
  const newImg = new Image();
151
164
  newImg.src = img.src;
152
165
  newImg.onload = done;
@@ -156,7 +169,48 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
156
169
  img.addEventListener('error', done, { once: true });
157
170
  }
158
171
  });
159
- }, [messages, messageObject]);
172
+
173
+ // fallback 타이머로 scrollToBottom 보장 (예: 이미지 로딩 실패 시)
174
+ const fallback = setTimeout(() => {
175
+ scrollToBottom();
176
+ }, 500); // 1초 후 강제 실행
177
+
178
+ return () => clearTimeout(fallback);
179
+ }, [sortedMessages, messageObject]);
180
+
181
+ // 무한 스크롤
182
+ useEffect(() => {
183
+ const container = messagesContainerRef.current;
184
+ if (!container || !isNextPage || !chatInquiryNumber || sortedMessages.length === 0) return;
185
+
186
+ const handleScroll = async () => {
187
+ const { scrollTop, scrollHeight, clientHeight } = container;
188
+
189
+ // 스크롤이 없더라도 무시하지 않음! → handleScroll은 무한스크롤 용도에만 사용
190
+ const scrolledPercent = (scrollTop / scrollHeight) * 100;
191
+
192
+ if (scrolledPercent < 5 && !isFetchingPrev) {
193
+ setIsFetchingPrev(true);
194
+ const prevScrollHeight = container.scrollHeight;
195
+ const oldestMessage = sortedMessages[0];
196
+ if (!oldestMessage?.createdAt) return;
197
+
198
+ try {
199
+ await getNextMessageList(chatInquiryNumber, oldestMessage.timestamp);
200
+ requestAnimationFrame(() => {
201
+ const newScrollHeight = container.scrollHeight;
202
+ container.scrollTop = newScrollHeight - prevScrollHeight;
203
+ });
204
+ } finally {
205
+ setIsFetchingPrev(false);
206
+ }
207
+ }
208
+ };
209
+ handleScroll();
210
+
211
+ container.addEventListener('scroll', handleScroll);
212
+ return () => container.removeEventListener('scroll', handleScroll);
213
+ }, [sortedMessages, chatInquiryNumber, isNextPage, isFetchingPrev, getNextMessageList]);
160
214
 
161
215
  const isNewDay = (date1: Date, date2: Date): boolean => {
162
216
  return (
@@ -168,9 +222,9 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
168
222
 
169
223
  const renderedMessages = useMemo(() => {
170
224
  const elements: React.ReactNode[] = [];
171
-
172
- const sortedMessages =
173
- messages && messages.length > 0 ? messages.sort((a, b) => a.timestamp - b.timestamp) : [];
225
+ if (sortedMessages.length < 1) {
226
+ return;
227
+ }
174
228
 
175
229
  sortedMessages.forEach((message, index) => {
176
230
  const findObject =
@@ -202,7 +256,7 @@ const ChatConversation: React.FC<ChatConversationProps> = ({
202
256
 
203
257
  return elements;
204
258
  }, [
205
- messages,
259
+ sortedMessages,
206
260
  messageObject, // 둘 다 바뀌면 리렌더됨
207
261
  isMobile,
208
262
  inquiryStatus,
@@ -4,8 +4,8 @@ const ChatWrapper = ({ isOperator, children, className = '' }) => {
4
4
  const customerClassName = 'border-drTalkBtnActive2 text-drTalkHover bg-drTalkGrayscale5';
5
5
  return (<div className={`
6
6
  ${isOperator ? operatorClassName : customerClassName} ${className}
7
- dr_talk_body_medium2 w-full whitespace-pre-line break-words
8
- rounded-[10px] border px-[12px] py-[8px]
7
+ dr_talk_body_medium2 w-full whitespace-pre-line
8
+ break-words rounded-[10px] border px-[12px] py-[8px]
9
9
  `}>
10
10
  {children}
11
11
  </div>);
@@ -13,8 +13,8 @@ const ChatWrapper = ({ isOperator, children, className = '' }: props) => {
13
13
  <div
14
14
  className={`
15
15
  ${isOperator ? operatorClassName : customerClassName} ${className}
16
- dr_talk_body_medium2 w-full whitespace-pre-line break-words
17
- rounded-[10px] border px-[12px] py-[8px]
16
+ dr_talk_body_medium2 w-full whitespace-pre-line
17
+ break-words rounded-[10px] border px-[12px] py-[8px]
18
18
  `}
19
19
  >
20
20
  {children}
@@ -82,7 +82,7 @@ const ChatMessage = ({ message, object, handelObjectBack, chatInquiryNumber, wor
82
82
  return (<div className={`flex flex-col gap-[10px]`}>
83
83
  {/* 텍스트 + 파일인경우 */}
84
84
  {isRichForm && (<TimeWrapper time={time}>
85
- <ChatWrapper isOperator={isOperator}>
85
+ <ChatWrapper isOperator={isOperator} className={` !w-fit `}>
86
86
  <RichText message={message}/>
87
87
  </ChatWrapper>
88
88
  </TimeWrapper>)}
@@ -115,7 +115,7 @@ const ChatMessage: React.FC<ChatMessageProps> = ({
115
115
  {/* 텍스트 + 파일인경우 */}
116
116
  {isRichForm && (
117
117
  <TimeWrapper time={time}>
118
- <ChatWrapper isOperator={isOperator}>
118
+ <ChatWrapper isOperator={isOperator} className={` !w-fit `}>
119
119
  <RichText message={message} />
120
120
  </ChatWrapper>
121
121
  </TimeWrapper>
@@ -25,7 +25,7 @@ const ChatWidget = ({ isOpen, isMobile, onClose, hashValue, setHashValue, animat
25
25
  ? ``
26
26
  : isOpen
27
27
  ? 'opacity-100 pointer-events-auto xs:translate-y-0 xs:duration-500'
28
- : 'opacity-0 pointer-events-none xs:translate-y-4 xs:duration-500 '}
28
+ : 'opacity-0 pointer-events-none xs:translate-y-4 xs:duration-500 xs:rounded-[30px] '}
29
29
  ${isHash
30
30
  ? `
31
31
  xs:fixed xs:flex xs:justify-center xs:items-center xs:inset-0 xs:bg-white
@@ -35,7 +35,7 @@ const ChatWidget = ({ isOpen, isMobile, onClose, hashValue, setHashValue, animat
35
35
  h-[100dvh] ease-in-out
36
36
  xs:bottom-[165px] xs:right-[25px] xs:max-w-[390px]
37
37
  xs:max-h-[690px] xs:rounded-[30px]
38
- lg:bottom-[100px]
38
+ lg:bottom-[100px] xs:rounded-[30px]
39
39
  `}
40
40
  `;
41
41
  //
@@ -47,7 +47,7 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({
47
47
  ? ``
48
48
  : isOpen
49
49
  ? 'opacity-100 pointer-events-auto xs:translate-y-0 xs:duration-500'
50
- : 'opacity-0 pointer-events-none xs:translate-y-4 xs:duration-500 '
50
+ : 'opacity-0 pointer-events-none xs:translate-y-4 xs:duration-500 xs:rounded-[30px] '
51
51
  }
52
52
  ${
53
53
  isHash
@@ -59,7 +59,7 @@ const ChatWidget: React.FC<ChatWidgetProps> = ({
59
59
  h-[100dvh] ease-in-out
60
60
  xs:bottom-[165px] xs:right-[25px] xs:max-w-[390px]
61
61
  xs:max-h-[690px] xs:rounded-[30px]
62
- lg:bottom-[100px]
62
+ lg:bottom-[100px] xs:rounded-[30px]
63
63
  `
64
64
  }
65
65
  `;
@@ -110,7 +110,7 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
110
110
 
111
111
  <div className={`absolute left-0 top-0 z-0 w-full overflow-hidden ${isMobile ? 'aspect-[16/9] max-h-[360px]' : 'h-full max-h-[360px]'}`}>
112
112
  {/*<div className={`relative`}>*/}
113
- <Image src={backgroundImage} alt="대화 배경" fill className={`will-change-transform ${isMobile ? 'object-cover object-center' : 'object-contain object-top'}`} priority/>
113
+ <Image src={backgroundImage} alt="대화 배경" fill className={`will-change-transform ${isMobile ? 'object-cover object-center' : ' object-cover object-top xs:object-contain '}`} priority/>
114
114
  <div className="pointer-events-none absolute bottom-0 left-0 h-24 w-full bg-gradient-to-t from-white to-transparent"/>
115
115
  {/*</div>*/}
116
116
  </div>
@@ -149,7 +149,7 @@ const HomeView = ({ inquiryMainData, isLoading, handleStartChat, isMobile, onClo
149
149
  alt="대화 배경"
150
150
  fill
151
151
  className={`will-change-transform ${
152
- isMobile ? 'object-cover object-center' : 'object-contain object-top'
152
+ isMobile ? 'object-cover object-center' : ' object-cover object-top xs:object-contain '
153
153
  }`}
154
154
  priority
155
155
  />
@@ -74,7 +74,7 @@ const MobileViewer = ({ imageViewerMessage, handleDownload, currentIndex, setCur
74
74
  {/* </div>*/}
75
75
  {/*</div>*/}
76
76
  {/* Thumbnail Preview */}
77
- <div className="relative flex items-center justify-center px-[20px] pb-[65px] pt-[40px]">
77
+ <div className="relative m-auto flex max-w-[350px] items-center justify-center px-[20px] pb-[65px] pt-[40px]">
78
78
  {previewImages.length > 1 ? (<Swiper spaceBetween={10} slidesPerView={Math.min(previewImages.length, 5)} watchSlidesProgress allowTouchMove>
79
79
  {previewImages.map((img, idx) => (<SwiperSlide key={idx} className={`!w-fit`}>
80
80
  <div onClick={() => {
@@ -84,7 +84,7 @@ const MobileViewer = ({ imageViewerMessage, handleDownload, currentIndex, setCur
84
84
  setZoomLevel(3);
85
85
  (_a = thumbSwiperRef.current) === null || _a === void 0 ? void 0 : _a.slideTo(idx); // 👈 스와이퍼 이동
86
86
  }} className={`
87
- relative
87
+ relative
88
88
  h-[50px] w-[50px] cursor-pointer overflow-hidden rounded-[10px] border-[1px]
89
89
  ${idx === currentIndex ? 'border-white' : 'opacity-50 hover:border-white hover:opacity-100'}
90
90
  `}>
@@ -120,7 +120,7 @@ const MobileViewer = ({
120
120
  {/* </div>*/}
121
121
  {/*</div>*/}
122
122
  {/* Thumbnail Preview */}
123
- <div className="relative flex items-center justify-center px-[20px] pb-[65px] pt-[40px]">
123
+ <div className="relative m-auto flex max-w-[350px] items-center justify-center px-[20px] pb-[65px] pt-[40px]">
124
124
  {previewImages.length > 1 ? (
125
125
  <Swiper
126
126
  spaceBetween={10}
@@ -138,7 +138,7 @@ const MobileViewer = ({
138
138
  thumbSwiperRef.current?.slideTo(idx); // 👈 스와이퍼 이동
139
139
  }}
140
140
  className={`
141
- relative
141
+ relative
142
142
  h-[50px] w-[50px] cursor-pointer overflow-hidden rounded-[10px] border-[1px]
143
143
  ${idx === currentIndex ? 'border-white' : 'opacity-50 hover:border-white hover:opacity-100'}
144
144
  `}
@@ -94,8 +94,10 @@ const TbPcViewer = ({ imageViewerMessage, handleDownload, currentIndex, setCurre
94
94
  </div>
95
95
 
96
96
  {/* Thumbnail Preview - 고정된 위치 */}
97
- {previewImages.length > 1 && (<div className="flex w-full max-w-[90vw] flex-row justify-center gap-[10px] overflow-x-auto px-[20px] md2:w-[830px]">
98
- <Swiper spaceBetween={10} slidesPerView={Math.min(previewImages.length, 5)} watchSlidesProgress allowTouchMove>
97
+ {previewImages.length > 1 && (<div className="flex w-full max-w-[90vw] flex-row justify-center gap-[10px] overflow-x-auto px-[20px] md2:max-w-[570px] ">
98
+ <Swiper spaceBetween={10}
99
+ // slidesPerView={Math.min(previewImages.length, 5)}
100
+ slidesPerView={Math.min(previewImages.length, 5)} watchSlidesProgress allowTouchMove>
99
101
  {previewImages.map((img, idx) => (<SwiperSlide key={idx} className={`!w-fit`}>
100
102
  <div onClick={() => {
101
103
  setCurrentIndex(idx);
@@ -169,9 +169,10 @@ const TbPcViewer = ({
169
169
 
170
170
  {/* Thumbnail Preview - 고정된 위치 */}
171
171
  {previewImages.length > 1 && (
172
- <div className="flex w-full max-w-[90vw] flex-row justify-center gap-[10px] overflow-x-auto px-[20px] md2:w-[830px]">
172
+ <div className="flex w-full max-w-[90vw] flex-row justify-center gap-[10px] overflow-x-auto px-[20px] md2:max-w-[570px] ">
173
173
  <Swiper
174
174
  spaceBetween={10}
175
+ // slidesPerView={Math.min(previewImages.length, 5)}
175
176
  slidesPerView={Math.min(previewImages.length, 5)}
176
177
  watchSlidesProgress
177
178
  allowTouchMove
@@ -59,7 +59,7 @@ export declare function getChatInquiryDetailNew(chat_inquiry_number: string, ver
59
59
  * @param version API 버전 (기본값: 1.0.0)
60
60
  * @returns 채팅 메세지 리스트
61
61
  */
62
- export declare function getChatInquiryMessageList(chatInquiryNumber: string, standardDateTime?: any, size?: number, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryMessageListDataResponse>>;
62
+ export declare function getChatInquiryMessageList(chatInquiryNumber: string, standardTimestamp?: number, size?: number, version?: string): Promise<IDaeryunTalkResponseWrapper<ChatInquiryMessageListDataResponse>>;
63
63
  /**
64
64
  * Daeryuntalk 초기화 완료 흐름
65
65
  * 이 함수는 인증부터 웹소켓 연결까지 완전한 흐름을 처리
@@ -401,12 +401,10 @@ export function getChatInquiryDetailNew(chat_inquiry_number, version) {
401
401
  * @param version API 버전 (기본값: 1.0.0)
402
402
  * @returns 채팅 메세지 리스트
403
403
  */
404
- export function getChatInquiryMessageList(chatInquiryNumber, standardDateTime, size, version) {
404
+ export function getChatInquiryMessageList(chatInquiryNumber, standardTimestamp, size, version) {
405
405
  return __awaiter(this, void 0, void 0, function* () {
406
406
  const body = {
407
- d: Object.assign(Object.assign({ chat_inquiry_number: chatInquiryNumber }, (standardDateTime && { standard_date_time: standardDateTime })), {
408
- // standard_date_time: standard_date_time ?? new Date().toISOString(),
409
- size: size !== null && size !== void 0 ? size : 400 })
407
+ d: Object.assign(Object.assign({ chat_inquiry_number: chatInquiryNumber }, (standardTimestamp && { standard_timestamp: standardTimestamp })), { size: size !== null && size !== void 0 ? size : 400 })
410
408
  };
411
409
  consoleFn('[채팅 메세지 리스트] 문의 번호:', chatInquiryNumber, version ? `버전: ${version}` : `기본 버전: ${DEFAULT_API_VERSION}`);
412
410
  try {
@@ -498,15 +498,14 @@ export async function getChatInquiryDetailNew(
498
498
  */
499
499
  export async function getChatInquiryMessageList(
500
500
  chatInquiryNumber: string,
501
- standardDateTime?: any,
501
+ standardTimestamp?: number,
502
502
  size?: number,
503
503
  version?: string
504
504
  ): Promise<IDaeryunTalkResponseWrapper<ChatInquiryMessageListDataResponse>> {
505
505
  const body = {
506
506
  d: {
507
507
  chat_inquiry_number: chatInquiryNumber,
508
- ...(standardDateTime && { standard_date_time: standardDateTime }),
509
- // standard_date_time: standard_date_time ?? new Date().toISOString(),
508
+ ...(standardTimestamp && { standard_timestamp: standardTimestamp }),
510
509
  size: size ?? 400
511
510
  }
512
511
  };
@@ -39,7 +39,7 @@ export declare const useChatHandler: ({ setIsLoading, inquiryMainData, setChatIn
39
39
  name: string;
40
40
  cellPhoneNumber: string;
41
41
  }) => Promise<import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<any> | undefined>;
42
- getNextMessageList: (chatInquiryNumber: string, standardDateTime: any) => Promise<void>;
42
+ getNextMessageList: (chatInquiryNumber: string, standardTimestamp: number) => Promise<void>;
43
43
  startSelectedChat: (chatInquiryNumber: string) => Promise<string | import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").ChatInquiryDetailDataResponse> | import("../../_api/daeryuntalk/type/response").IDaeryunTalkResponseWrapper<import("../../_api/daeryuntalk/type/response").ChatInquiryMessageListDataResponse>>;
44
44
  };
45
45
  export {};
@@ -77,8 +77,10 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
77
77
  // 메세지 리스트 후처리
78
78
  if (chatList.data.message_list.length > 0) {
79
79
  const uiMessages = chatList.data.message_list
80
- .sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
81
- .map(convertApiMessageToUiMessage);
80
+ .sort((a, b) => a.timestamp - b.timestamp)
81
+ .map(item => {
82
+ return convertApiMessageToUiMessage(item, 'basic');
83
+ });
82
84
  setMessages(uiMessages);
83
85
  consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
84
86
  }
@@ -151,9 +153,10 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
151
153
  // 메세지 리스트 후처리
152
154
  if (chatList.data.message_list.length > 0) {
153
155
  const uiMessages = chatList.data.message_list
154
- .sort((a, b) => a.timestamp - b.timestamp) // timestamp 오름차순 (최신이 마지막에)
155
- .map(convertApiMessageToUiMessage);
156
- setMessages(uiMessages);
156
+ .sort((a, b) => a.timestamp - b.timestamp)
157
+ .map(item => {
158
+ return convertApiMessageToUiMessage(item, 'basic');
159
+ });
157
160
  // const uiMessages = chatList.data.message_list.map(convertApiMessageToUiMessage);
158
161
  setMessages(uiMessages);
159
162
  consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
@@ -250,8 +253,10 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
250
253
  // 메세지 리스트 후처리
251
254
  if (((_a = chatList.data) === null || _a === void 0 ? void 0 : _a.message_list) && chatList.data.message_list.length > 0) {
252
255
  const uiMessages = chatList.data.message_list
253
- .sort((a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime())
254
- .map(convertApiMessageToUiMessage);
256
+ .sort((a, b) => a.timestamp - b.timestamp)
257
+ .map(item => {
258
+ return convertApiMessageToUiMessage(item, 'basic');
259
+ });
255
260
  setMessages(uiMessages);
256
261
  consoleFn('[DaeryuntalkContext] 메시지 설정 완료:', uiMessages.length);
257
262
  }
@@ -378,24 +383,21 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
378
383
  setIsLoading === null || setIsLoading === void 0 ? void 0 : setIsLoading(false);
379
384
  }
380
385
  }), []);
381
- const getNextMessageList = useCallback((chatInquiryNumber, standardDateTime) => __awaiter(void 0, void 0, void 0, function* () {
386
+ // 무한스크롤 실행
387
+ const getNextMessageList = useCallback((chatInquiryNumber, standardTimestamp) => __awaiter(void 0, void 0, void 0, function* () {
382
388
  try {
383
- const response = yield getChatInquiryMessageList(chatInquiryNumber, standardDateTime);
389
+ const response = yield getChatInquiryMessageList(chatInquiryNumber, standardTimestamp);
384
390
  if (response.result_info.result_cd === 'OK' || response.result_info.result_type_cd === 'OK') {
385
- // 앞에 생성될 여기서는 앞에서부터 채워야함
386
391
  const newMessageList = response.data.message_list
387
392
  .sort((a, b) => a.timestamp - b.timestamp)
388
- .map(item => {
389
- return convertApiMessageToUiMessage(item);
390
- });
393
+ .map(item => convertApiMessageToUiMessage(item, 'prev'));
391
394
  setIsNextPage(response.data.next_page_yn);
392
395
  setMessages(prev => {
393
- if (newMessageList && newMessageList.length > 0) {
394
- return [...newMessageList, ...prev];
395
- }
396
- else {
397
- return [...prev];
398
- }
396
+ if (!newMessageList || newMessageList.length === 0)
397
+ return prev;
398
+ const existingMessageNumbers = new Set(prev.map(msg => msg.messageNumber));
399
+ const filteredNewMessages = newMessageList.filter(msg => !existingMessageNumbers.has(msg.messageNumber));
400
+ return [...filteredNewMessages, ...prev];
399
401
  });
400
402
  }
401
403
  else {
@@ -405,7 +407,6 @@ export const useChatHandler = ({ setIsLoading, inquiryMainData, setChatInquiryNu
405
407
  }
406
408
  catch (error) {
407
409
  console.error(`[실패]:`, error);
408
- // toast.error(error?.message || '오류가 발생했습니다.');
409
410
  }
410
411
  }), []);
411
412
  const attendRoomByHistory = useCallback((chatInquiryNumber) => __awaiter(void 0, void 0, void 0, function* () {