Skip to content

Commit afad442

Browse files
authored
fix: Prevent bouncing pending message (#990)
[SBISSUE-15149](https://sendbird.atlassian.net/browse/SBISSUE-15149) ### Fix * Remove highlighted message system * Set animated message id with null instead of 0 ### ChangeLog * Prevent bouncing pending message
1 parent 4543aa3 commit afad442

File tree

5 files changed

+6
-117
lines changed

5 files changed

+6
-117
lines changed

src/modules/Channel/components/Message/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const Message = (props: MessageProps): React.ReactElement => {
1313
const {
1414
initialized,
1515
currentGroupChannel,
16-
highLightedMessageId,
17-
setHighLightedMessageId,
1816
animatedMessageId,
1917
setAnimatedMessageId,
2018
updateMessage,
@@ -32,7 +30,6 @@ const Message = (props: MessageProps): React.ReactElement => {
3230
onReplyInThread,
3331
onQuoteMessageClick,
3432
onMessageAnimated,
35-
onMessageHighlighted,
3633
sendMessage,
3734
localMessages,
3835
} = useChannelContext();
@@ -88,9 +85,6 @@ const Message = (props: MessageProps): React.ReactElement => {
8885
animatedMessageId={animatedMessageId}
8986
setAnimatedMessageId={setAnimatedMessageId}
9087
onMessageAnimated={onMessageAnimated}
91-
highLightedMessageId={highLightedMessageId}
92-
setHighLightedMessageId={setHighLightedMessageId}
93-
onMessageHighlighted={onMessageHighlighted}
9488
renderFileViewer={(props) => <FileViewer {...props} />}
9589
renderRemoveMessageModal={(props) => <RemoveMessageModal {...props} />}
9690
/>

src/modules/Channel/context/ChannelProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const ChannelProvider: React.FC<ChannelContextProps> = (props: ChannelContextPro
219219
useEffect(() => {
220220
setInitialTimeStamp(startingPoint);
221221
}, [startingPoint, channelUrl]);
222-
const [animatedMessageId, setAnimatedMessageId] = useState(0);
222+
const [animatedMessageId, setAnimatedMessageId] = useState<number | null>(null);
223223
const [highLightedMessageId, setHighLightedMessageId] = useState(highlightedMessage);
224224
useEffect(() => {
225225
setHighLightedMessageId(highlightedMessage);

src/modules/GroupChannel/components/GroupChannelUI/index.scss

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,6 @@
3535
padding: 0px 0px 24px 0px;
3636
}
3737

38-
@keyframes sbHighlight {
39-
0% {
40-
background-color: #FFF2B6;
41-
}
42-
99% {
43-
background-color: #FFF2B6;
44-
}
45-
}
46-
47-
@keyframes sbTextHighlight {
48-
0% {
49-
color: var(--sendbird-dark-onlight-01);
50-
}
51-
99% {
52-
color: var(--sendbird-dark-onlight-01);
53-
}
54-
}
55-
56-
@keyframes sbHighlightBlock {
57-
0% {
58-
opacity: 0.5;
59-
background-color: #FFF2B6;
60-
}
61-
99% {
62-
opacity: 0.5;
63-
background-color: #FFF2B6;
64-
}
65-
}
66-
6738
.sendbird-msg-hoc__animated {
6839
.sendbird-message-content {
6940
animation: bounce 1s ease;
@@ -76,51 +47,6 @@
7647
}
7748
}
7849

79-
.sendbird-msg-hoc__highlighted {
80-
.sendbird-text-message-item-body,
81-
.sendbird-file-message-item-body {
82-
animation-name: sbHighlight;
83-
animation-duration: 1.6s;
84-
animation-fill-mode: forwards;
85-
}
86-
87-
.sendbird-text-message-item-body__message,
88-
.sendbird-file-message-item-body__file-name__text {
89-
animation-name: sbTextHighlight;
90-
animation-duration: 1.6s;
91-
animation-fill-mode: forwards;
92-
}
93-
94-
.sendbird-voice-message-item-body {
95-
display: block;
96-
animation-name: sbHighlightBlock;
97-
animation-duration: 1.6s;
98-
animation-fill-mode: forwards;
99-
}
100-
101-
.sendbird-thumbnail-message-item-body
102-
.sendbird-thumbnail-message-item-body__image-cover {
103-
display: block;
104-
animation-name: sbHighlightBlock;
105-
animation-duration: 1.6s;
106-
animation-fill-mode: forwards;
107-
}
108-
109-
.sendbird-og-message-item-body
110-
.sendbird-og-message-item-body__cover {
111-
display: block;
112-
animation-name: sbHighlightBlock;
113-
animation-duration: 1.6s;
114-
animation-fill-mode: forwards;
115-
}
116-
117-
.sendbird-message-content-reactions {
118-
animation-name: sbHighlight;
119-
animation-duration: 1.6s;
120-
animation-fill-mode: forwards;
121-
}
122-
}
123-
12450
.sendbird-conversation__scroll-container {
12551
display: flex;
12652
height: 100%;

src/modules/GroupChannel/components/Message/MessageView.tsx

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,6 @@ const MessageView = (props: MessageViewProps) => {
138138
setAnimatedMessageId,
139139
animatedMessageId,
140140
onMessageAnimated,
141-
highLightedMessageId,
142-
setHighLightedMessageId,
143-
onMessageHighlighted,
144141
} = props;
145142

146143
const { dateLocale, stringSet } = useLocalization();
@@ -154,7 +151,6 @@ const MessageView = (props: MessageViewProps) => {
154151
const [showRemove, setShowRemove] = useState(false);
155152
const [showFileViewer, setShowFileViewer] = useState(false);
156153
const [isAnimated, setIsAnimated] = useState(false);
157-
const [isHighlighted, setIsHighlighted] = useState(false);
158154
const [mentionNickname, setMentionNickname] = useState('');
159155
const [mentionedUsers, setMentionedUsers] = useState([]);
160156
const [mentionedUserIds, setMentionedUserIds] = useState([]);
@@ -200,36 +196,10 @@ const MessageView = (props: MessageViewProps) => {
200196
handleScroll?.(true);
201197
}, []);
202198

203-
useLayoutEffect(() => {
204-
const timeouts = [];
205-
206-
if (highLightedMessageId === message.messageId && messageScrollRef?.current) {
207-
setIsAnimated(false);
208-
timeouts.push(
209-
setTimeout(() => {
210-
setIsHighlighted(true);
211-
}, 500),
212-
);
213-
timeouts.push(
214-
setTimeout(() => {
215-
setHighLightedMessageId(0);
216-
onMessageHighlighted?.();
217-
}, 1600),
218-
);
219-
} else {
220-
setIsHighlighted(false);
221-
}
222-
return () => {
223-
timeouts.forEach((it) => clearTimeout(it));
224-
};
225-
}, [highLightedMessageId, messageScrollRef.current, message.messageId]);
226-
227199
useLayoutEffect(() => {
228200
const timeouts = [];
229201

230202
if (animatedMessageId === message.messageId && messageScrollRef?.current) {
231-
setIsHighlighted(false);
232-
233203
timeouts.push(
234204
setTimeout(() => {
235205
setIsAnimated(true);
@@ -238,7 +208,7 @@ const MessageView = (props: MessageViewProps) => {
238208

239209
timeouts.push(
240210
setTimeout(() => {
241-
setAnimatedMessageId(0);
211+
setAnimatedMessageId(null);
242212
onMessageAnimated?.();
243213
}, 1600),
244214
);
@@ -398,7 +368,6 @@ const MessageView = (props: MessageViewProps) => {
398368
className={getClassName([
399369
'sendbird-msg-hoc sendbird-msg--scroll-ref',
400370
isAnimated ? 'sendbird-msg-hoc__animated' : '',
401-
isHighlighted ? 'sendbird-msg-hoc__highlighted' : '',
402371
])}
403372
style={children || renderMessage ? undefined : { marginBottom: '2px' }}
404373
data-sb-message-id={message.messageId}

src/modules/GroupChannel/context/GroupChannelProvider.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export const GroupChannelProvider = (props: GroupChannelProviderProps) => {
140140

141141
// State
142142
const [quoteMessage, setQuoteMessage] = useState<SendableMessageType>(null);
143-
const [animatedMessageId, setAnimatedMessageId] = useState(0);
143+
const [animatedMessageId, setAnimatedMessageId] = useState<number | null>(null);
144144
const [currentChannel, setCurrentChannel] = useState<GroupChannel | null>(null);
145145
const [fetchChannelError, setFetchChannelError] = useState<SendbirdError>(null);
146146

@@ -259,7 +259,7 @@ export const GroupChannelProvider = (props: GroupChannelProviderProps) => {
259259
} finally {
260260
// Reset states when channel changes
261261
setQuoteMessage(null);
262-
setAnimatedMessageId(0);
262+
setAnimatedMessageId(null);
263263
}
264264
}
265265
}, [sdkStore.initialized, sdkStore.sdk, channelUrl]);
@@ -309,7 +309,7 @@ export const GroupChannelProvider = (props: GroupChannelProviderProps) => {
309309
const scrollToBottom = usePreservedCallback(async () => {
310310
if (!scrollRef.current) return;
311311

312-
setAnimatedMessageId(0);
312+
setAnimatedMessageId(null);
313313
setIsScrollBottomReached(true);
314314

315315
if (config.isOnline && messageDataSource.hasNext()) {
@@ -345,7 +345,7 @@ export const GroupChannelProvider = (props: GroupChannelProviderProps) => {
345345

346346
clickHandler.deactivate();
347347

348-
setAnimatedMessageId(0);
348+
setAnimatedMessageId(null);
349349
const message = messageDataSource.messages.find((it) => it.messageId === messageId || it.createdAt === createdAt);
350350
if (message) {
351351
const topOffset = getMessageTopOffset(message.createdAt);

0 commit comments

Comments
 (0)