Messages: Fix deleting in the selected messages modal (#4927)
This commit is contained in:
parent
a59a3a4217
commit
342a3d92da
@ -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]);
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user