Messages: Fix deleting in the selected messages modal (#4927)

This commit is contained in:
Alexander Zinchuk 2024-09-06 15:43:25 +02:00
parent a59a3a4217
commit 342a3d92da
3 changed files with 27 additions and 24 deletions

View File

@ -20,13 +20,13 @@ import {
isUserId, isUserId,
} from '../../global/helpers'; } from '../../global/helpers';
import { import {
getSendersFromSelectedMessages,
selectCanDeleteSelectedMessages, selectCanDeleteSelectedMessages,
selectChatFullInfo, selectChatFullInfo,
selectCurrentChat, selectCurrentChat,
selectCurrentMessageIds, selectCurrentMessageIds,
selectCurrentMessageList, selectCurrentMessageList,
selectSenderFromMessage, selectSenderFromMessage,
selectSendersFromSelectedMessages,
selectTabState, selectTabState,
selectUser, selectUser,
} from '../../global/selectors'; } from '../../global/selectors';
@ -119,7 +119,8 @@ const DeleteSelectedMessageModal: FC<OwnProps & StateProps> = ({
if (isChannel) { if (isChannel) {
return undefined; return undefined;
} }
return selectSendersFromSelectedMessages(getGlobal(), chat); const senderArray = getSendersFromSelectedMessages(getGlobal(), chat);
return senderArray?.filter(Boolean);
// eslint-disable-next-line react-hooks-static-deps/exhaustive-deps // eslint-disable-next-line react-hooks-static-deps/exhaustive-deps
}, [chat, isChannel, isOpen]); }, [chat, isChannel, isOpen]);

View File

@ -213,30 +213,32 @@ addActionHandler('loadViewportMessages', (global, actions, payload): ActionRetur
const isOutlying = Boolean(listedIds && !listedIds.includes(offsetId)); const isOutlying = Boolean(listedIds && !listedIds.includes(offsetId));
const historyIds = (isOutlying const historyIds = (isOutlying
? selectOutlyingListByMessageId(global, chatId, threadId, offsetId) : listedIds)!; ? selectOutlyingListByMessageId(global, chatId, threadId, offsetId) : listedIds)!;
const { if (historyIds?.length) {
newViewportIds, areSomeLocal, areAllLocal, const {
} = getViewportSlice(historyIds, offsetId, direction); newViewportIds, areSomeLocal, areAllLocal,
} = getViewportSlice(historyIds, offsetId, direction);
if (areSomeLocal) { if (areSomeLocal) {
global = safeReplaceViewportIds(global, chatId, threadId, newViewportIds, tabId); global = safeReplaceViewportIds(global, chatId, threadId, newViewportIds, tabId);
}
onTickEnd(() => {
void loadWithBudget(
global,
actions,
areAllLocal,
isOutlying,
isBudgetPreload,
chat,
threadId!,
direction,
offsetId,
onLoaded,
tabId,
);
});
} }
onTickEnd(() => {
void loadWithBudget(
global,
actions,
areAllLocal,
isOutlying,
isBudgetPreload,
chat,
threadId!,
direction,
offsetId,
onLoaded,
tabId,
);
});
if (isBudgetPreload) { if (isBudgetPreload) {
return; return;
} }

View File

@ -420,7 +420,7 @@ export function selectSender<T extends GlobalState>(global: T, message: ApiMessa
return selectPeer(global, senderId); return selectPeer(global, senderId);
} }
export function selectSendersFromSelectedMessages<T extends GlobalState>( export function getSendersFromSelectedMessages<T extends GlobalState>(
global: T, global: T,
chat: ApiChat | undefined, chat: ApiChat | undefined,
...[tabId = getCurrentTabId()]: TabArgs<T> ...[tabId = getCurrentTabId()]: TabArgs<T>