mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-27 12:55:11 +01:00
Pinned Message: Fix updating after pin/unpin
This commit is contained in:
parent
414c88f345
commit
18aeb7abe7
@ -134,15 +134,10 @@ const MiddleHeader: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
}
|
||||
}, [chatId, loadPinnedMessages, lastSyncTime, threadId]);
|
||||
|
||||
// Modify pinned index after unpinning
|
||||
useEffect(() => {
|
||||
setPinnedMessageIndex(pinnedMessagesCount ? cycleRestrict(pinnedMessagesCount, pinnedMessageIndex) : -1);
|
||||
}, [pinnedMessagesCount, pinnedMessageIndex]);
|
||||
|
||||
// Reset pinned index when switching chats
|
||||
// Reset pinned index when switching chats and pinning/unpinning
|
||||
useEffect(() => {
|
||||
setPinnedMessageIndex(0);
|
||||
}, [chatId]);
|
||||
}, [pinnedMessageIds]);
|
||||
|
||||
useEnsureMessage(chatId, pinnedMessageId, pinnedMessage);
|
||||
|
||||
|
@ -201,7 +201,7 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => {
|
||||
|
||||
const currentPinnedIds = selectPinnedIds(global, chatId) || [];
|
||||
const newPinnedIds = isPinned
|
||||
? [...currentPinnedIds, ...messageIds]
|
||||
? [...currentPinnedIds, ...messageIds].sort((a, b) => b - a)
|
||||
: currentPinnedIds.filter((id) => !messageIds.includes(id));
|
||||
|
||||
setGlobal(replaceThreadParam(global, chatId, MAIN_THREAD_ID, 'pinnedIds', newPinnedIds));
|
||||
|
Loading…
Reference in New Issue
Block a user