@webitel/ui-chats 26.12.1 → 26.12.3
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/package.json +1 -1
- package/src/shared/composables/__tests__/useChatScroll.spec.ts +149 -1
- package/src/shared/composables/useChatScroll.ts +66 -7
- package/src/v2/scripts/__tests__/isOutgoingMessage.spec.ts +118 -0
- package/src/v2/scripts/isOutgoingMessage.ts +33 -0
- package/src/v2/ui/chat-history/__tests__/chat-history.spec.ts +29 -0
- package/src/v2/ui/chat-history/components/chat-message.vue +8 -2
- package/types/.tsbuildinfo +1 -1
- package/types/v2/scripts/isOutgoingMessage.d.ts +18 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mount } from '@vue/test-utils';
|
|
2
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
3
|
import { computed, defineComponent, h, nextTick, ref } from 'vue';
|
|
4
4
|
|
|
5
5
|
import { useChatScroll } from '../useChatScroll';
|
|
@@ -162,3 +162,151 @@ describe('useChatScroll — thread switch during a pending load', () => {
|
|
|
162
162
|
wrapper.unmount();
|
|
163
163
|
});
|
|
164
164
|
});
|
|
165
|
+
|
|
166
|
+
describe('useChatScroll — fullscreen enter/exit', () => {
|
|
167
|
+
let fullscreenElement: Element | null = null;
|
|
168
|
+
|
|
169
|
+
const toggleFullscreen = (el: Element | null) => {
|
|
170
|
+
fullscreenElement = el;
|
|
171
|
+
document.dispatchEvent(new Event('fullscreenchange'));
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// [Claude] happy-dom has no layout: emulate scroll metrics and the browser clamping scrollTop
|
|
175
|
+
const mockScrollMetrics = (
|
|
176
|
+
el: HTMLElement,
|
|
177
|
+
metrics: {
|
|
178
|
+
scrollHeight: number;
|
|
179
|
+
clientHeight: number;
|
|
180
|
+
scrollTop: number;
|
|
181
|
+
},
|
|
182
|
+
) => {
|
|
183
|
+
const clamp = (top: number) =>
|
|
184
|
+
Math.max(0, Math.min(top, metrics.scrollHeight - metrics.clientHeight));
|
|
185
|
+
Object.defineProperty(el, 'scrollHeight', {
|
|
186
|
+
configurable: true,
|
|
187
|
+
get: () => metrics.scrollHeight,
|
|
188
|
+
});
|
|
189
|
+
Object.defineProperty(el, 'clientHeight', {
|
|
190
|
+
configurable: true,
|
|
191
|
+
get: () => metrics.clientHeight,
|
|
192
|
+
});
|
|
193
|
+
Object.defineProperty(el, 'scrollTop', {
|
|
194
|
+
configurable: true,
|
|
195
|
+
get: () => metrics.scrollTop,
|
|
196
|
+
set: (top: number) => {
|
|
197
|
+
metrics.scrollTop = clamp(top);
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
el.scrollTo = ((options: ScrollToOptions) => {
|
|
201
|
+
metrics.scrollTop = clamp(options.top ?? 0);
|
|
202
|
+
}) as typeof el.scrollTo;
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
scroll: () => el.dispatchEvent(new Event('scroll')),
|
|
206
|
+
resizeViewport: (clientHeight: number) => {
|
|
207
|
+
const prevScrollTop = metrics.scrollTop;
|
|
208
|
+
metrics.clientHeight = clientHeight;
|
|
209
|
+
metrics.scrollTop = clamp(metrics.scrollTop);
|
|
210
|
+
if (metrics.scrollTop !== prevScrollTop)
|
|
211
|
+
el.dispatchEvent(new Event('scroll'));
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const mountChat = async () => {
|
|
217
|
+
const container = ref<HTMLElement | null>(null);
|
|
218
|
+
const content = ref<HTMLElement | null>(null);
|
|
219
|
+
const Host = defineComponent({
|
|
220
|
+
setup() {
|
|
221
|
+
useChatScroll({
|
|
222
|
+
chatContainer: container,
|
|
223
|
+
chatContent: content,
|
|
224
|
+
messages: computed(() => []),
|
|
225
|
+
chatId: computed(() => 'c1'),
|
|
226
|
+
isChatClosed: computed(() => false),
|
|
227
|
+
});
|
|
228
|
+
return () =>
|
|
229
|
+
h(
|
|
230
|
+
'div',
|
|
231
|
+
{
|
|
232
|
+
ref: container,
|
|
233
|
+
},
|
|
234
|
+
[
|
|
235
|
+
h('div', {
|
|
236
|
+
ref: content,
|
|
237
|
+
}),
|
|
238
|
+
],
|
|
239
|
+
);
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
const wrapper = mount(Host);
|
|
243
|
+
await nextTick();
|
|
244
|
+
await nextTick();
|
|
245
|
+
return {
|
|
246
|
+
wrapper,
|
|
247
|
+
el: container.value as HTMLElement,
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
beforeEach(() => {
|
|
252
|
+
vi.useFakeTimers();
|
|
253
|
+
fullscreenElement = null;
|
|
254
|
+
Object.defineProperty(document, 'fullscreenElement', {
|
|
255
|
+
configurable: true,
|
|
256
|
+
get: () => fullscreenElement,
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
afterEach(() => {
|
|
261
|
+
vi.useRealTimers();
|
|
262
|
+
delete (
|
|
263
|
+
document as {
|
|
264
|
+
fullscreenElement?: Element | null;
|
|
265
|
+
}
|
|
266
|
+
).fullscreenElement;
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('brings the chat back to the bottom after the window shrinks on exit', async () => {
|
|
270
|
+
const { wrapper, el } = await mountChat();
|
|
271
|
+
const metrics = {
|
|
272
|
+
scrollHeight: 2273,
|
|
273
|
+
clientHeight: 380,
|
|
274
|
+
scrollTop: 1893,
|
|
275
|
+
};
|
|
276
|
+
const chat = mockScrollMetrics(el, metrics);
|
|
277
|
+
chat.scroll();
|
|
278
|
+
|
|
279
|
+
toggleFullscreen(document.createElement('div'));
|
|
280
|
+
chat.resizeViewport(557); // the browser clamps scrollTop to 1716
|
|
281
|
+
vi.advanceTimersByTime(1000);
|
|
282
|
+
|
|
283
|
+
toggleFullscreen(null);
|
|
284
|
+
chat.resizeViewport(380);
|
|
285
|
+
vi.advanceTimersByTime(1000);
|
|
286
|
+
|
|
287
|
+
expect(metrics.scrollTop).toBe(1893);
|
|
288
|
+
wrapper.unmount();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
it('keeps a position above the bottom instead of snapping to the bottom', async () => {
|
|
292
|
+
const { wrapper, el } = await mountChat();
|
|
293
|
+
const metrics = {
|
|
294
|
+
scrollHeight: 2273,
|
|
295
|
+
clientHeight: 380,
|
|
296
|
+
scrollTop: 1800,
|
|
297
|
+
};
|
|
298
|
+
const chat = mockScrollMetrics(el, metrics);
|
|
299
|
+
chat.scroll();
|
|
300
|
+
|
|
301
|
+
toggleFullscreen(document.createElement('div'));
|
|
302
|
+
chat.resizeViewport(557); // clamped to the bottom while in fullscreen
|
|
303
|
+
vi.advanceTimersByTime(1000);
|
|
304
|
+
|
|
305
|
+
toggleFullscreen(null);
|
|
306
|
+
chat.resizeViewport(380);
|
|
307
|
+
vi.advanceTimersByTime(1000);
|
|
308
|
+
|
|
309
|
+
expect(metrics.scrollTop).toBe(1800);
|
|
310
|
+
wrapper.unmount();
|
|
311
|
+
});
|
|
312
|
+
});
|
|
@@ -40,6 +40,11 @@ export interface UseChatScrollOptions<TItem = unknown> {
|
|
|
40
40
|
onSeen?: () => void;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
interface ScrollPosition {
|
|
44
|
+
top: number;
|
|
45
|
+
atBottom: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
const isSelfByMember = (item: unknown): boolean =>
|
|
44
49
|
!!(
|
|
45
50
|
item as
|
|
@@ -65,7 +70,9 @@ export const useChatScroll = <TItem = unknown>({
|
|
|
65
70
|
},
|
|
66
71
|
onSeen,
|
|
67
72
|
}: UseChatScrollOptions<TItem>) => {
|
|
68
|
-
const { arrivedState } = useScroll(chatContainer
|
|
73
|
+
const { arrivedState } = useScroll(chatContainer, {
|
|
74
|
+
onScroll: () => rememberScrollPosition(),
|
|
75
|
+
});
|
|
69
76
|
|
|
70
77
|
const {
|
|
71
78
|
showScrollToBottomBtn,
|
|
@@ -82,6 +89,9 @@ export const useChatScroll = <TItem = unknown>({
|
|
|
82
89
|
let resizeObserver: ResizeObserver | null = null;
|
|
83
90
|
let isViewportTransition = false;
|
|
84
91
|
let viewportTransitionTimer: ReturnType<typeof setTimeout> | null = null;
|
|
92
|
+
let fullscreenElement = document.fullscreenElement;
|
|
93
|
+
let lastScrollPosition: ScrollPosition | null = null;
|
|
94
|
+
let scrollPositionBeforeFullscreen: ScrollPosition | null = null;
|
|
85
95
|
/**
|
|
86
96
|
* @author PolinaSukhorukova-webitel
|
|
87
97
|
*
|
|
@@ -101,6 +111,23 @@ export const useChatScroll = <TItem = unknown>({
|
|
|
101
111
|
el.clientHeight > 0 &&
|
|
102
112
|
el.scrollHeight - (el.scrollTop + el.clientHeight) <= bottomThreshold;
|
|
103
113
|
|
|
114
|
+
const readScrollPosition = (el: HTMLElement): ScrollPosition => ({
|
|
115
|
+
top: el.scrollTop,
|
|
116
|
+
atBottom: isViewingBottom(el),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const rememberScrollPosition = () => {
|
|
120
|
+
const el = chatContainer.value;
|
|
121
|
+
// [Claude] while fullscreen toggles, scroll events come from the browser clamping scrollTop, not from the viewer
|
|
122
|
+
if (
|
|
123
|
+
!el ||
|
|
124
|
+
isViewportTransition ||
|
|
125
|
+
document.fullscreenElement !== fullscreenElement
|
|
126
|
+
)
|
|
127
|
+
return;
|
|
128
|
+
lastScrollPosition = readScrollPosition(el);
|
|
129
|
+
};
|
|
130
|
+
|
|
104
131
|
const markSeenIfAtBottom = () => {
|
|
105
132
|
const el = chatContainer.value;
|
|
106
133
|
if (el && isViewingBottom(el)) onSeen?.();
|
|
@@ -165,6 +192,7 @@ export const useChatScroll = <TItem = unknown>({
|
|
|
165
192
|
const newScrollHeight = el.scrollHeight;
|
|
166
193
|
|
|
167
194
|
if (isViewportTransition) {
|
|
195
|
+
restoreScrollPositionAfterFullscreen();
|
|
168
196
|
prevScrollHeight = newScrollHeight;
|
|
169
197
|
prevScrollTop = el.scrollTop;
|
|
170
198
|
updateScrollToBottomBtnVisibility(el);
|
|
@@ -212,13 +240,20 @@ export const useChatScroll = <TItem = unknown>({
|
|
|
212
240
|
resizeObserver = null;
|
|
213
241
|
};
|
|
214
242
|
|
|
215
|
-
useResizeObserver(
|
|
216
|
-
|
|
217
|
-
|
|
243
|
+
useResizeObserver(
|
|
244
|
+
[
|
|
245
|
+
chatContainer,
|
|
246
|
+
chatContent,
|
|
247
|
+
],
|
|
248
|
+
() => {
|
|
249
|
+
const el = chatContainer.value;
|
|
250
|
+
if (!el) return;
|
|
218
251
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
252
|
+
if (isViewportTransition) restoreScrollPositionAfterFullscreen();
|
|
253
|
+
updateThreshold(el.clientHeight);
|
|
254
|
+
updateScrollToBottomBtnVisibility(el);
|
|
255
|
+
},
|
|
256
|
+
);
|
|
222
257
|
|
|
223
258
|
const resetScrollState = () => {
|
|
224
259
|
stopStickToBottomObserving();
|
|
@@ -226,12 +261,34 @@ export const useChatScroll = <TItem = unknown>({
|
|
|
226
261
|
// anchor into this one
|
|
227
262
|
isLoadingNextMessages = false;
|
|
228
263
|
lastVisibleMessageEl = null;
|
|
264
|
+
lastScrollPosition = null;
|
|
265
|
+
scrollPositionBeforeFullscreen = null;
|
|
229
266
|
prevScrollHeight = 0;
|
|
230
267
|
newUnseenMessagesCount.value = 0;
|
|
231
268
|
resetScrollToBottomBtn();
|
|
232
269
|
};
|
|
233
270
|
|
|
271
|
+
/**
|
|
272
|
+
* [Claude] The browser window resizes when fullscreen toggles, so the browser clamps
|
|
273
|
+
* scrollTop and does not reliably give it back on exit.
|
|
274
|
+
* Bring back the position the viewer had before entering fullscreen.
|
|
275
|
+
*/
|
|
276
|
+
const restoreScrollPositionAfterFullscreen = () => {
|
|
277
|
+
const el = chatContainer.value;
|
|
278
|
+
const position = scrollPositionBeforeFullscreen;
|
|
279
|
+
if (!el || !position || document.fullscreenElement) return;
|
|
280
|
+
|
|
281
|
+
if (position.atBottom) scrollToBottom('instant');
|
|
282
|
+
else el.scrollTop = position.top;
|
|
283
|
+
};
|
|
284
|
+
|
|
234
285
|
const onFullscreenChange = () => {
|
|
286
|
+
const el = chatContainer.value;
|
|
287
|
+
if (el && document.fullscreenElement && !fullscreenElement) {
|
|
288
|
+
scrollPositionBeforeFullscreen =
|
|
289
|
+
lastScrollPosition ?? readScrollPosition(el);
|
|
290
|
+
}
|
|
291
|
+
fullscreenElement = document.fullscreenElement;
|
|
235
292
|
isViewportTransition = true;
|
|
236
293
|
|
|
237
294
|
if (viewportTransitionTimer) clearTimeout(viewportTransitionTimer);
|
|
@@ -239,6 +296,8 @@ export const useChatScroll = <TItem = unknown>({
|
|
|
239
296
|
viewportTransitionTimer = setTimeout(() => {
|
|
240
297
|
isViewportTransition = false;
|
|
241
298
|
viewportTransitionTimer = null;
|
|
299
|
+
restoreScrollPositionAfterFullscreen();
|
|
300
|
+
if (!document.fullscreenElement) scrollPositionBeforeFullscreen = null;
|
|
242
301
|
}, 1000);
|
|
243
302
|
};
|
|
244
303
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { isInternalThread, isOutgoingMessage } from '../isOutgoingMessage';
|
|
4
|
+
import { bot, client, colleague, message, operator, thread } from './fixtures';
|
|
5
|
+
|
|
6
|
+
const internalThread = thread({
|
|
7
|
+
members: [
|
|
8
|
+
operator,
|
|
9
|
+
colleague,
|
|
10
|
+
bot,
|
|
11
|
+
],
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('isInternalThread', () => {
|
|
15
|
+
it('is a thread with no client', () => {
|
|
16
|
+
expect(isInternalThread(internalThread)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('is not a thread with a client', () => {
|
|
20
|
+
expect(isInternalThread(thread())).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('is not a thread whose members are not known', () => {
|
|
24
|
+
expect(
|
|
25
|
+
isInternalThread(
|
|
26
|
+
thread({
|
|
27
|
+
members: [],
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
).toBe(false);
|
|
31
|
+
expect(
|
|
32
|
+
isInternalThread(
|
|
33
|
+
thread({
|
|
34
|
+
members: undefined,
|
|
35
|
+
}),
|
|
36
|
+
),
|
|
37
|
+
).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('isOutgoingMessage', () => {
|
|
42
|
+
describe('with a client in the thread', () => {
|
|
43
|
+
const withClient = thread({
|
|
44
|
+
members: [
|
|
45
|
+
operator,
|
|
46
|
+
colleague,
|
|
47
|
+
bot,
|
|
48
|
+
client,
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it.each([
|
|
53
|
+
[
|
|
54
|
+
'the operator',
|
|
55
|
+
operator,
|
|
56
|
+
],
|
|
57
|
+
[
|
|
58
|
+
'a colleague',
|
|
59
|
+
colleague,
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
'a bot',
|
|
63
|
+
bot,
|
|
64
|
+
],
|
|
65
|
+
])('puts %s on the operator’s side', (_who, sender) => {
|
|
66
|
+
expect(
|
|
67
|
+
isOutgoingMessage({
|
|
68
|
+
message: message({
|
|
69
|
+
sender,
|
|
70
|
+
}),
|
|
71
|
+
thread: withClient,
|
|
72
|
+
selfMemberId: operator.id,
|
|
73
|
+
}),
|
|
74
|
+
).toBe(true);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('puts the client on the other side', () => {
|
|
78
|
+
expect(
|
|
79
|
+
isOutgoingMessage({
|
|
80
|
+
message: message({
|
|
81
|
+
sender: client,
|
|
82
|
+
}),
|
|
83
|
+
thread: withClient,
|
|
84
|
+
selfMemberId: operator.id,
|
|
85
|
+
}),
|
|
86
|
+
).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('between colleagues', () => {
|
|
91
|
+
it('puts only the operator on the operator’s side', () => {
|
|
92
|
+
const outgoing = (sender: typeof operator) =>
|
|
93
|
+
isOutgoingMessage({
|
|
94
|
+
message: message({
|
|
95
|
+
sender,
|
|
96
|
+
}),
|
|
97
|
+
thread: internalThread,
|
|
98
|
+
selfMemberId: operator.id,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(outgoing(operator)).toBe(true);
|
|
102
|
+
expect(outgoing(colleague)).toBe(false);
|
|
103
|
+
expect(outgoing(bot)).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('puts nobody on it while the operator’s member is unknown', () => {
|
|
107
|
+
expect(
|
|
108
|
+
isOutgoingMessage({
|
|
109
|
+
message: message({
|
|
110
|
+
sender: operator,
|
|
111
|
+
}),
|
|
112
|
+
thread: internalThread,
|
|
113
|
+
selfMemberId: '',
|
|
114
|
+
}),
|
|
115
|
+
).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { MessageModel, ThreadModel } from '../types';
|
|
2
|
+
import { isContactCentreSide } from './isContactCentreSide';
|
|
3
|
+
import { isSelfMessage } from './isSelfMessage';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A thread with no client in it: every member is an operator or a bot, as in
|
|
7
|
+
* a chat between colleagues. A thread whose members are not known is not
|
|
8
|
+
* taken for one.
|
|
9
|
+
*/
|
|
10
|
+
export const isInternalThread = (thread: ThreadModel): boolean => {
|
|
11
|
+
const members = thread.members ?? [];
|
|
12
|
+
|
|
13
|
+
return members.length > 0 && members.every(isContactCentreSide);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Which side of the history a message sits on. With a client in the thread,
|
|
18
|
+
* everyone who speaks for the contact centre (operators, bots) shares the
|
|
19
|
+
* operator's side against the client. Between colleagues there is no such
|
|
20
|
+
* opposition, so only the operator using the UI sits on it.
|
|
21
|
+
*/
|
|
22
|
+
export const isOutgoingMessage = ({
|
|
23
|
+
message,
|
|
24
|
+
thread,
|
|
25
|
+
selfMemberId,
|
|
26
|
+
}: {
|
|
27
|
+
message: MessageModel;
|
|
28
|
+
thread: ThreadModel;
|
|
29
|
+
selfMemberId: string;
|
|
30
|
+
}): boolean =>
|
|
31
|
+
isInternalThread(thread)
|
|
32
|
+
? isSelfMessage(message, thread, selfMemberId)
|
|
33
|
+
: isContactCentreSide(message.sender);
|
|
@@ -2,7 +2,9 @@ import { flushPromises } from '@vue/test-utils';
|
|
|
2
2
|
import { describe, expect, it, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
+
bot,
|
|
5
6
|
client,
|
|
7
|
+
colleague,
|
|
6
8
|
message,
|
|
7
9
|
operator,
|
|
8
10
|
thread,
|
|
@@ -86,6 +88,33 @@ describe('ChatHistory', () => {
|
|
|
86
88
|
expect(rows[1].classes()).toContain('chat-message--outgoing');
|
|
87
89
|
});
|
|
88
90
|
|
|
91
|
+
it('puts only the operator on the outgoing side between colleagues', () => {
|
|
92
|
+
const wrapper = setup({
|
|
93
|
+
thread: thread({
|
|
94
|
+
members: [
|
|
95
|
+
operator,
|
|
96
|
+
colleague,
|
|
97
|
+
bot,
|
|
98
|
+
],
|
|
99
|
+
}),
|
|
100
|
+
messages: [
|
|
101
|
+
message({
|
|
102
|
+
sender: colleague,
|
|
103
|
+
}),
|
|
104
|
+
message({
|
|
105
|
+
sender: bot,
|
|
106
|
+
}),
|
|
107
|
+
message({
|
|
108
|
+
sender: operator,
|
|
109
|
+
}),
|
|
110
|
+
],
|
|
111
|
+
});
|
|
112
|
+
const rows = wrapper.findAll('.chat-message');
|
|
113
|
+
expect(rows[0].classes()).not.toContain('chat-message--outgoing');
|
|
114
|
+
expect(rows[1].classes()).not.toContain('chat-message--outgoing');
|
|
115
|
+
expect(rows[2].classes()).toContain('chat-message--outgoing');
|
|
116
|
+
});
|
|
117
|
+
|
|
89
118
|
it('shows ticks only on the operator’s own messages', () => {
|
|
90
119
|
const wrapper = setup({
|
|
91
120
|
messages: [
|
|
@@ -59,7 +59,7 @@ import { useChatsV2I18n } from '../../../locale/useChatsV2I18n';
|
|
|
59
59
|
import { hasAttachments } from '../../../scripts/attachments';
|
|
60
60
|
import { formatMessageTime } from '../../../scripts/formatDate';
|
|
61
61
|
import { getMessageStatus } from '../../../scripts/getMessageStatus';
|
|
62
|
-
import {
|
|
62
|
+
import { isOutgoingMessage } from '../../../scripts/isOutgoingMessage';
|
|
63
63
|
import { participantName } from '../../../scripts/resolveSystemNotice';
|
|
64
64
|
import { toTimestamp } from '../../../scripts/toTimestamp';
|
|
65
65
|
import type {
|
|
@@ -80,7 +80,13 @@ const props = defineProps<{
|
|
|
80
80
|
|
|
81
81
|
const { t } = useChatsV2I18n();
|
|
82
82
|
|
|
83
|
-
const isOutgoing = computed(() =>
|
|
83
|
+
const isOutgoing = computed(() =>
|
|
84
|
+
isOutgoingMessage({
|
|
85
|
+
message: props.message,
|
|
86
|
+
thread: props.thread,
|
|
87
|
+
selfMemberId: props.selfMemberId,
|
|
88
|
+
}),
|
|
89
|
+
);
|
|
84
90
|
|
|
85
91
|
const authorName = computed(() => participantName(props.message.sender));
|
|
86
92
|
|