stream-chat-react-native-core 9.7.3 → 9.7.4
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/lib/commonjs/components/Attachment/Attachment.js +1 -1
- package/lib/commonjs/components/Attachment/Attachment.js.map +1 -1
- package/lib/commonjs/components/Attachment/Audio/PlayPauseButton.js +1 -1
- package/lib/commonjs/components/Attachment/Audio/PlayPauseButton.js.map +1 -1
- package/lib/commonjs/components/Attachment/UrlPreview/URLPreview.js +16 -18
- package/lib/commonjs/components/Attachment/UrlPreview/URLPreview.js.map +1 -1
- package/lib/commonjs/components/Attachment/UrlPreview/URLPreviewCompact.js +16 -18
- package/lib/commonjs/components/Attachment/UrlPreview/URLPreviewCompact.js.map +1 -1
- package/lib/commonjs/components/Message/MessageItemView/MessageItemView.js +1 -2
- package/lib/commonjs/components/Message/MessageItemView/MessageItemView.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageFlashList.js +3 -1
- package/lib/commonjs/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +3 -1
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/Poll/Poll.js +5 -3
- package/lib/commonjs/components/Poll/Poll.js.map +1 -1
- package/lib/commonjs/components/Poll/components/Button.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollButtons.js.map +1 -1
- package/lib/commonjs/components/Poll/components/PollOption.js +20 -10
- package/lib/commonjs/components/Poll/components/PollOption.js.map +1 -1
- package/lib/commonjs/components/Reply/Reply.js +19 -10
- package/lib/commonjs/components/Reply/Reply.js.map +1 -1
- package/lib/commonjs/contexts/themeContext/ThemeContext.js +8 -1
- package/lib/commonjs/contexts/themeContext/ThemeContext.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Attachment.js +1 -1
- package/lib/module/components/Attachment/Attachment.js.map +1 -1
- package/lib/module/components/Attachment/Audio/PlayPauseButton.js +1 -1
- package/lib/module/components/Attachment/Audio/PlayPauseButton.js.map +1 -1
- package/lib/module/components/Attachment/UrlPreview/URLPreview.js +16 -18
- package/lib/module/components/Attachment/UrlPreview/URLPreview.js.map +1 -1
- package/lib/module/components/Attachment/UrlPreview/URLPreviewCompact.js +16 -18
- package/lib/module/components/Attachment/UrlPreview/URLPreviewCompact.js.map +1 -1
- package/lib/module/components/Message/MessageItemView/MessageItemView.js +1 -2
- package/lib/module/components/Message/MessageItemView/MessageItemView.js.map +1 -1
- package/lib/module/components/MessageList/MessageFlashList.js +3 -1
- package/lib/module/components/MessageList/MessageFlashList.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +3 -1
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/Poll/Poll.js +5 -3
- package/lib/module/components/Poll/Poll.js.map +1 -1
- package/lib/module/components/Poll/components/Button.js.map +1 -1
- package/lib/module/components/Poll/components/PollButtons.js.map +1 -1
- package/lib/module/components/Poll/components/PollOption.js +20 -10
- package/lib/module/components/Poll/components/PollOption.js.map +1 -1
- package/lib/module/components/Reply/Reply.js +19 -10
- package/lib/module/components/Reply/Reply.js.map +1 -1
- package/lib/module/contexts/themeContext/ThemeContext.js +8 -1
- package/lib/module/contexts/themeContext/ThemeContext.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/UrlPreview/URLPreview.d.ts.map +1 -1
- package/lib/typescript/components/Attachment/UrlPreview/URLPreviewCompact.d.ts.map +1 -1
- package/lib/typescript/components/Message/MessageItemView/MessageItemView.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageFlashList.d.ts.map +1 -1
- package/lib/typescript/components/MessageList/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/Poll/Poll.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/Button.d.ts +5 -0
- package/lib/typescript/components/Poll/components/Button.d.ts.map +1 -1
- package/lib/typescript/components/Poll/components/PollOption.d.ts +1 -1
- package/lib/typescript/components/Poll/components/PollOption.d.ts.map +1 -1
- package/lib/typescript/components/Reply/Reply.d.ts +1 -0
- package/lib/typescript/components/Reply/Reply.d.ts.map +1 -1
- package/lib/typescript/contexts/themeContext/ThemeContext.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Attachment/Attachment.tsx +1 -1
- package/src/components/Attachment/Audio/PlayPauseButton.tsx +1 -1
- package/src/components/Attachment/Audio/__tests__/PlayPauseButton.test.tsx +44 -0
- package/src/components/Attachment/UrlPreview/URLPreview.tsx +4 -8
- package/src/components/Attachment/UrlPreview/URLPreviewCompact.tsx +4 -8
- package/src/components/Attachment/UrlPreview/__tests__/URLPreview.test.tsx +92 -0
- package/src/components/Attachment/__tests__/Attachment.test.tsx +48 -0
- package/src/components/Message/MessageItemView/MessageItemView.tsx +1 -2
- package/src/components/Message/MessageItemView/__tests__/MessageTextContainer.test.tsx +20 -2
- package/src/components/Message/MessageItemView/__tests__/__snapshots__/MessageAuthor.test.tsx.snap +2 -2
- package/src/components/MessageList/MessageFlashList.tsx +4 -2
- package/src/components/MessageList/MessageList.tsx +4 -2
- package/src/components/Poll/Poll.tsx +5 -3
- package/src/components/Poll/__tests__/Poll.test.tsx +70 -0
- package/src/components/Poll/components/Button.tsx +5 -0
- package/src/components/Poll/components/PollButtons.tsx +2 -0
- package/src/components/Poll/components/PollOption.tsx +22 -21
- package/src/components/Poll/components/__tests__/PollOption.test.tsx +99 -0
- package/src/components/Reply/Reply.tsx +20 -13
- package/src/components/Reply/__tests__/Reply.test.tsx +111 -1
- package/src/contexts/themeContext/ThemeContext.tsx +5 -1
- package/src/version.json +1 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { render, screen } from '@testing-library/react-native';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
OwnCapabilitiesProvider,
|
|
8
|
+
PollContextProvider,
|
|
9
|
+
ThemeProvider,
|
|
10
|
+
TranslationProvider,
|
|
11
|
+
} from '../../../../contexts';
|
|
12
|
+
import { mergeThemes } from '../../../../contexts/themeContext/ThemeContext';
|
|
13
|
+
import { generateMessage } from '../../../../mock-builders/generator/message';
|
|
14
|
+
import { PollOption } from '../PollOption';
|
|
15
|
+
|
|
16
|
+
const option = { id: 'option-1', text: 'An option' };
|
|
17
|
+
|
|
18
|
+
const mockIsPollCreatedByCurrentUser = jest.fn();
|
|
19
|
+
|
|
20
|
+
jest.mock('../../hook/useIsPollCreatedByCurrentUser', () => ({
|
|
21
|
+
useIsPollCreatedByCurrentUser: () => mockIsPollCreatedByCurrentUser(),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
jest.mock('../../hooks/usePollState', () => ({
|
|
25
|
+
usePollState: () => ({
|
|
26
|
+
isClosed: false,
|
|
27
|
+
latestVotesByOption: {},
|
|
28
|
+
ownVotesByOptionId: {},
|
|
29
|
+
voteCount: 4,
|
|
30
|
+
voteCountsByOption: { 'option-1': 2 },
|
|
31
|
+
}),
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
jest.mock('../../hooks/usePollVoteToggle', () => ({
|
|
35
|
+
usePollVoteToggle: () => jest.fn(),
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
describe('PollOption chat text side', () => {
|
|
39
|
+
const lightTheme = mergeThemes({ scheme: 'light' });
|
|
40
|
+
|
|
41
|
+
const renderOption = ({ forceIncoming }: { forceIncoming?: boolean } = {}) =>
|
|
42
|
+
render(
|
|
43
|
+
<ThemeProvider>
|
|
44
|
+
<TranslationProvider value={{ t: (key: string) => key } as never}>
|
|
45
|
+
<OwnCapabilitiesProvider value={{ castPollVote: true } as never}>
|
|
46
|
+
<PollContextProvider
|
|
47
|
+
value={{ message: generateMessage(), poll: { data: {} } as never }}
|
|
48
|
+
>
|
|
49
|
+
<PollOption forceIncoming={forceIncoming} option={option as never} />
|
|
50
|
+
</PollContextProvider>
|
|
51
|
+
</OwnCapabilitiesProvider>
|
|
52
|
+
</TranslationProvider>
|
|
53
|
+
</ThemeProvider>,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const optionTextColor = () =>
|
|
57
|
+
StyleSheet.flatten(screen.getByText('An option').props.style)?.color;
|
|
58
|
+
|
|
59
|
+
const voteButtonBorderColor = () => {
|
|
60
|
+
const style = screen.getByLabelText('An option').props.style;
|
|
61
|
+
return StyleSheet.flatten(typeof style === 'function' ? style({ pressed: false }) : style)
|
|
62
|
+
?.borderColor;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
afterEach(() => {
|
|
66
|
+
mockIsPollCreatedByCurrentUser.mockReset();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('uses the outgoing chat text colour for our own poll', () => {
|
|
70
|
+
mockIsPollCreatedByCurrentUser.mockReturnValue(true);
|
|
71
|
+
renderOption();
|
|
72
|
+
|
|
73
|
+
expect(optionTextColor()).toBe(lightTheme.semantics.chatTextOutgoing);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("uses the incoming chat text colour for another user's poll", () => {
|
|
77
|
+
mockIsPollCreatedByCurrentUser.mockReturnValue(false);
|
|
78
|
+
renderOption();
|
|
79
|
+
|
|
80
|
+
expect(optionTextColor()).toBe(lightTheme.semantics.chatTextIncoming);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// The full-options list is a neutral card, not a bubble, so `forceIncoming`
|
|
84
|
+
// has to win over ownership for every token - the vote button included.
|
|
85
|
+
it('forces incoming text and vote button border on our own poll', () => {
|
|
86
|
+
mockIsPollCreatedByCurrentUser.mockReturnValue(true);
|
|
87
|
+
renderOption({ forceIncoming: true });
|
|
88
|
+
|
|
89
|
+
expect(optionTextColor()).toBe(lightTheme.semantics.chatTextIncoming);
|
|
90
|
+
expect(voteButtonBorderColor()).toBe(lightTheme.semantics.chatBorderOnChatIncoming);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('uses the outgoing vote button border for our own poll in the bubble', () => {
|
|
94
|
+
mockIsPollCreatedByCurrentUser.mockReturnValue(true);
|
|
95
|
+
renderOption();
|
|
96
|
+
|
|
97
|
+
expect(voteButtonBorderColor()).toBe(lightTheme.semantics.chatBorderOnChatOutgoing);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -99,6 +99,7 @@ export type ReplyPropsWithContext = { ImageComponent: React.ComponentType<ImageP
|
|
|
99
99
|
> &
|
|
100
100
|
Pick<MessagesContextValue, 'quotedMessage'> & {
|
|
101
101
|
isMyMessage: boolean;
|
|
102
|
+
isParentMessageMine?: boolean;
|
|
102
103
|
onDismiss?: () => void;
|
|
103
104
|
mode: 'reply' | 'edit';
|
|
104
105
|
// This is temporary for the MessageContent Component to style the Reply component
|
|
@@ -116,6 +117,7 @@ export const ReplyWithContext = (props: ReplyPropsWithContext) => {
|
|
|
116
117
|
const { t } = useTranslationContext();
|
|
117
118
|
const {
|
|
118
119
|
isMyMessage,
|
|
120
|
+
isParentMessageMine = isMyMessage,
|
|
119
121
|
ImageComponent,
|
|
120
122
|
message: messageFromContext,
|
|
121
123
|
mode,
|
|
@@ -135,7 +137,7 @@ export const ReplyWithContext = (props: ReplyPropsWithContext) => {
|
|
|
135
137
|
},
|
|
136
138
|
},
|
|
137
139
|
} = useTheme();
|
|
138
|
-
const styles = useStyles();
|
|
140
|
+
const styles = useStyles({ isMyMessage: isParentMessageMine });
|
|
139
141
|
|
|
140
142
|
const title = useMemo(
|
|
141
143
|
() =>
|
|
@@ -165,7 +167,8 @@ export const ReplyWithContext = (props: ReplyPropsWithContext) => {
|
|
|
165
167
|
{title}
|
|
166
168
|
</Text>
|
|
167
169
|
|
|
168
|
-
|
|
170
|
+
{/* `isMyMessage` here selects which side to paint, so it takes the surface. */}
|
|
171
|
+
<ReplyMessageView message={quotedMessage} isMyMessage={isParentMessageMine} />
|
|
169
172
|
</View>
|
|
170
173
|
<View style={[styles.rightContainer, rightContainer, stylesProp?.rightContainer]}>
|
|
171
174
|
<RightContent ImageComponent={ImageComponent} message={quotedMessage} />
|
|
@@ -187,6 +190,7 @@ const areEqual = (prevProps: ReplyPropsWithContext, nextProps: ReplyPropsWithCon
|
|
|
187
190
|
const {
|
|
188
191
|
styles: prevStyles,
|
|
189
192
|
isMyMessage: prevIsMyMessage,
|
|
193
|
+
isParentMessageMine: prevIsParentMessageMine,
|
|
190
194
|
mode: prevMode,
|
|
191
195
|
quotedMessage: prevQuotedMessage,
|
|
192
196
|
onDismiss: prevOnDismiss,
|
|
@@ -194,6 +198,7 @@ const areEqual = (prevProps: ReplyPropsWithContext, nextProps: ReplyPropsWithCon
|
|
|
194
198
|
const {
|
|
195
199
|
styles: nextStyles,
|
|
196
200
|
isMyMessage: nextIsMyMessage,
|
|
201
|
+
isParentMessageMine: nextIsParentMessageMine,
|
|
197
202
|
mode: nextMode,
|
|
198
203
|
quotedMessage: nextQuotedMessage,
|
|
199
204
|
onDismiss: nextOnDismiss,
|
|
@@ -209,6 +214,12 @@ const areEqual = (prevProps: ReplyPropsWithContext, nextProps: ReplyPropsWithCon
|
|
|
209
214
|
return false;
|
|
210
215
|
}
|
|
211
216
|
|
|
217
|
+
const isParentMessageMineEqual = prevIsParentMessageMine === nextIsParentMessageMine;
|
|
218
|
+
|
|
219
|
+
if (!isParentMessageMineEqual) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
|
|
212
223
|
const modeEqual = prevMode === nextMode;
|
|
213
224
|
if (!modeEqual) {
|
|
214
225
|
return false;
|
|
@@ -275,7 +286,7 @@ const ReplyComposerAnnouncer = ({
|
|
|
275
286
|
};
|
|
276
287
|
|
|
277
288
|
export const Reply = (props: ReplyProps) => {
|
|
278
|
-
const { message: messageFromContext } = useMessageContext();
|
|
289
|
+
const { isMyMessage: isMyMessageFromContext, message: messageFromContext } = useMessageContext();
|
|
279
290
|
const { client } = useChatContext();
|
|
280
291
|
const { ImageComponent } = useComponentsContext();
|
|
281
292
|
|
|
@@ -289,7 +300,10 @@ export const Reply = (props: ReplyProps) => {
|
|
|
289
300
|
? (messageFromContext.quoted_message as MessagesContextValue['quotedMessage'])
|
|
290
301
|
: quotedMessageFromComposer;
|
|
291
302
|
|
|
292
|
-
|
|
303
|
+
// `mode='edit'` supplies the edited message via `props.quotedMessage` and leaves
|
|
304
|
+
// the composer's quoted message empty, so ownership must consider both.
|
|
305
|
+
const isMyMessage = client.user?.id === (props.quotedMessage ?? quotedMessage)?.user?.id;
|
|
306
|
+
const isParentMessageMine = messageFromContext ? !!isMyMessageFromContext : undefined;
|
|
293
307
|
|
|
294
308
|
// Composer header passes `onDismiss`; the in-message quoted-reply renderer
|
|
295
309
|
// does not. Only the composer-preview path pays for announcement work.
|
|
@@ -305,6 +319,7 @@ export const Reply = (props: ReplyProps) => {
|
|
|
305
319
|
<MemoizedReply
|
|
306
320
|
ImageComponent={ImageComponent}
|
|
307
321
|
isMyMessage={isMyMessage}
|
|
322
|
+
isParentMessageMine={isParentMessageMine}
|
|
308
323
|
message={messageFromContext}
|
|
309
324
|
quotedMessage={quotedMessage}
|
|
310
325
|
{...props}
|
|
@@ -313,18 +328,10 @@ export const Reply = (props: ReplyProps) => {
|
|
|
313
328
|
);
|
|
314
329
|
};
|
|
315
330
|
|
|
316
|
-
const useStyles = () => {
|
|
331
|
+
const useStyles = ({ isMyMessage = false }: { isMyMessage?: boolean } = {}) => {
|
|
317
332
|
const {
|
|
318
333
|
theme: { semantics },
|
|
319
334
|
} = useTheme();
|
|
320
|
-
const messageComposer = useMessageComposer();
|
|
321
|
-
const { quotedMessage: quotedMessageFromComposer } = useStateStore(
|
|
322
|
-
messageComposer.state,
|
|
323
|
-
messageComposerStateStoreSelector,
|
|
324
|
-
);
|
|
325
|
-
const { client } = useChatContext();
|
|
326
|
-
|
|
327
|
-
const isMyMessage = client.user?.id === quotedMessageFromComposer?.user?.id;
|
|
328
335
|
const isRTL = I18nManager.isRTL;
|
|
329
336
|
|
|
330
337
|
return useMemo(
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native';
|
|
2
3
|
|
|
3
4
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
4
5
|
|
|
5
|
-
import { render, waitFor } from '@testing-library/react-native';
|
|
6
|
+
import { render, screen, waitFor } from '@testing-library/react-native';
|
|
6
7
|
|
|
8
|
+
import type { MessageContextValue } from '../../../contexts/messageContext/MessageContext';
|
|
9
|
+
import { MessageProvider } from '../../../contexts/messageContext/MessageContext';
|
|
7
10
|
import { OverlayProvider } from '../../../contexts/overlayContext/OverlayProvider';
|
|
11
|
+
import { mergeThemes } from '../../../contexts/themeContext/ThemeContext';
|
|
8
12
|
import { getOrCreateChannelApi } from '../../../mock-builders/api/getOrCreateChannel';
|
|
9
13
|
import { useMockedApis } from '../../../mock-builders/api/useMockedApis';
|
|
10
14
|
import { generateChannelResponse } from '../../../mock-builders/generator/channel';
|
|
15
|
+
import { generateMessage } from '../../../mock-builders/generator/message';
|
|
16
|
+
import { generateUser } from '../../../mock-builders/generator/user';
|
|
11
17
|
import { getTestClientWithUser } from '../../../mock-builders/mock';
|
|
12
18
|
import { Channel } from '../../Channel/Channel';
|
|
13
19
|
import { Chat } from '../../Chat/Chat';
|
|
@@ -49,4 +55,108 @@ describe('<Reply/>', () => {
|
|
|
49
55
|
|
|
50
56
|
process.env = oldEnvironment;
|
|
51
57
|
});
|
|
58
|
+
|
|
59
|
+
describe('chat text side', () => {
|
|
60
|
+
const lightTheme = mergeThemes({ scheme: 'light' });
|
|
61
|
+
|
|
62
|
+
const setup = async () => {
|
|
63
|
+
const chatClient = await getTestClientWithUser({ id: 'neil' });
|
|
64
|
+
const mockedChannel = generateChannelResponse();
|
|
65
|
+
useMockedApis(chatClient, [getOrCreateChannelApi(mockedChannel)]);
|
|
66
|
+
const channel = chatClient.channel('messaging', 'some-chat');
|
|
67
|
+
await channel.watch();
|
|
68
|
+
return { chatClient, channel };
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const titleColor = (title: string) =>
|
|
72
|
+
StyleSheet.flatten(screen.getByText(title).props.style)?.color;
|
|
73
|
+
|
|
74
|
+
// An in-message quoted reply is painted inside the parent bubble, whose
|
|
75
|
+
// background `MessageContent` resolves from the parent message. The colours
|
|
76
|
+
// must follow that surface; only the title *copy* describes the quoted author.
|
|
77
|
+
// The composer holds no quoted message in either case, so these also pin that
|
|
78
|
+
// the block never styles itself from composer state.
|
|
79
|
+
const renderInMessageQuotedReply = (
|
|
80
|
+
{ chatClient, channel }: Awaited<ReturnType<typeof setup>>,
|
|
81
|
+
{
|
|
82
|
+
isMyMessage,
|
|
83
|
+
quotedMessageUser,
|
|
84
|
+
}: { isMyMessage: boolean; quotedMessageUser: { id: string; name?: string } },
|
|
85
|
+
) => {
|
|
86
|
+
const quotedMessage = generateMessage({ user: quotedMessageUser });
|
|
87
|
+
const message = generateMessage({
|
|
88
|
+
quoted_message: quotedMessage,
|
|
89
|
+
quoted_message_id: quotedMessage.id,
|
|
90
|
+
user: isMyMessage ? { id: 'neil' } : generateUser(),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
render(
|
|
94
|
+
<GestureHandlerRootView>
|
|
95
|
+
<OverlayProvider>
|
|
96
|
+
<Chat client={chatClient}>
|
|
97
|
+
<Channel channel={channel} client={chatClient}>
|
|
98
|
+
<MessageProvider value={{ isMyMessage, message } as unknown as MessageContextValue}>
|
|
99
|
+
<Reply mode='reply' />
|
|
100
|
+
</MessageProvider>
|
|
101
|
+
</Channel>
|
|
102
|
+
</Chat>
|
|
103
|
+
</OverlayProvider>
|
|
104
|
+
</GestureHandlerRootView>,
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
it('styles an in-message quoted reply from the parent message, not the quoted author', async () => {
|
|
109
|
+
const setupResult = await setup();
|
|
110
|
+
|
|
111
|
+
// Our own message quoting somebody else: outgoing surface, so outgoing text
|
|
112
|
+
// even though the quoted author is not us.
|
|
113
|
+
renderInMessageQuotedReply(setupResult, {
|
|
114
|
+
isMyMessage: true,
|
|
115
|
+
quotedMessageUser: { id: 'other-user', name: 'Other User' },
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
expect(titleColor('Reply to Other User')).toBe(lightTheme.semantics.chatTextOutgoing);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('keeps the title copy on the quoted author while the colours follow the parent', async () => {
|
|
124
|
+
const setupResult = await setup();
|
|
125
|
+
|
|
126
|
+
// Somebody else's message quoting us: incoming surface, so incoming text -
|
|
127
|
+
// but the title still reads "You", because that describes the quoted author.
|
|
128
|
+
renderInMessageQuotedReply(setupResult, {
|
|
129
|
+
isMyMessage: false,
|
|
130
|
+
quotedMessageUser: { id: 'neil' },
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
await waitFor(() => {
|
|
134
|
+
expect(titleColor('You')).toBe(lightTheme.semantics.chatTextIncoming);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('uses outgoing colors for the edit-mode composer header', async () => {
|
|
139
|
+
const { chatClient, channel } = await setup();
|
|
140
|
+
|
|
141
|
+
// `mode='edit'` supplies the message through props and leaves the
|
|
142
|
+
// composer's quoted message empty - you can only ever edit your own message.
|
|
143
|
+
const editedMessage = generateMessage({ user: { id: 'neil' } });
|
|
144
|
+
|
|
145
|
+
render(
|
|
146
|
+
<GestureHandlerRootView>
|
|
147
|
+
<OverlayProvider>
|
|
148
|
+
<Chat client={chatClient}>
|
|
149
|
+
<Channel channel={channel} client={chatClient}>
|
|
150
|
+
<Reply mode='edit' quotedMessage={editedMessage} />
|
|
151
|
+
</Channel>
|
|
152
|
+
</Chat>
|
|
153
|
+
</OverlayProvider>
|
|
154
|
+
</GestureHandlerRootView>,
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
await waitFor(() => {
|
|
158
|
+
expect(titleColor('Edit Message')).toBe(lightTheme.semantics.chatTextOutgoing);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
});
|
|
52
162
|
});
|
|
@@ -39,7 +39,11 @@ export const mergeThemes = (params: MergedThemesParams) => {
|
|
|
39
39
|
: JSON.parse(JSON.stringify(theme))
|
|
40
40
|
) as Theme;
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
let semantics = scheme === 'dark' ? darkSemantics : lightSemantics;
|
|
43
|
+
if (theme?.semantics) {
|
|
44
|
+
semantics = { ...semantics, ...theme.semantics };
|
|
45
|
+
}
|
|
46
|
+
semantics = resolveTokensTopologically(semantics);
|
|
43
47
|
|
|
44
48
|
const finalTheme = { ...baseTheme, semantics };
|
|
45
49
|
|
package/src/version.json
CHANGED