Skip to content
Permalink
Browse files
fix delete all
  • Loading branch information
luvletter2333 committed Mar 24, 2022
1 parent 2f86e87 commit 00f7b2c89255fd4509a66bfd3c7c0bb784d65cf8
Showing 4 changed files with 14 additions and 29 deletions.
@@ -4968,38 +4968,26 @@ public void pinMessage(TLRPC.Chat chat, TLRPC.User user, int id, boolean unpin,
});
}

public void deleteUserChannelHistory(TLRPC.Chat chat, TLRPC.User user, int offset) {
if (offset == 0) {
getMessagesStorage().deleteUserChatHistory(-chat.id, user.id);
public void deleteUserChannelHistory(TLRPC.Chat currentChat, TLRPC.User fromUser, TLRPC.Chat fromChat, int offset) {
long fromId = 0;
if (fromUser != null) {
fromId = fromUser.id;
} else if (fromChat != null){
fromId = fromChat.id;
}
TLRPC.TL_channels_deleteParticipantHistory req = new TLRPC.TL_channels_deleteParticipantHistory();
req.channel = getInputChannel(chat);
req.participant = getInputPeer(user);
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
if (res.offset > 0) {
deleteUserChannelHistory(chat, user, res.offset);
}
processNewChannelDifferenceParams(res.pts, res.pts_count, chat.id);
}
});
}

public void deleteChannelUserChatHistory(TLRPC.Chat chat, TLRPC.Chat fromChat, int offset) {
if (offset == 0) {
getMessagesStorage().deleteUserChatHistory(-chat.id, fromChat.id);
getMessagesStorage().deleteUserChatHistory(-currentChat.id, fromId);
}
TLRPC.TL_channels_deleteParticipantHistory req = new TLRPC.TL_channels_deleteParticipantHistory();
req.channel = getInputChannel(chat);
req.participant = getInputPeer(fromChat);
req.channel = getInputChannel(currentChat);
req.participant = fromUser != null ? getInputPeer(fromUser) : getInputPeer(fromChat);
getConnectionsManager().sendRequest(req, (response, error) -> {
if (error == null) {
TLRPC.TL_messages_affectedHistory res = (TLRPC.TL_messages_affectedHistory) response;
if (res.offset > 0) {
deleteChannelUserChatHistory(chat, fromChat, res.offset);
deleteUserChannelHistory(currentChat, fromUser, fromChat, res.offset);
}
processNewChannelDifferenceParams(res.pts, res.pts_count, chat.id);
processNewChannelDifferenceParams(res.pts, res.pts_count, currentChat.id);
}
});
}
@@ -29052,7 +29052,7 @@ private void nkbtn_onclick_actionbar(int id) {
messageTextView.setText(AndroidUtilities.replaceTags(LocaleController.getString("DeleteAllFromSelfAlert", R.string.DeleteAllFromSelfAlert)));
builder.setPositiveButton(LocaleController.getString("DeleteAll", R.string.DeleteAll), (dialogInterface, i) -> {
if (ChatObject.isChannel(currentChat) && currentChat.megagroup && ChatObject.canUserDoAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES)) {
getMessagesController().deleteUserChannelHistory(currentChat, UserConfig.getInstance(currentAccount).getCurrentUser(), 0);
getMessagesController().deleteUserChannelHistory(currentChat, UserConfig.getInstance(currentAccount).getCurrentUser(), null, 0);
} else {
getMessageHelper().deleteUserChannelHistoryWithSearch(getParentActivity(), dialog_id, UserConfig.getInstance(currentAccount).getCurrentUser());
}
@@ -4588,10 +4588,7 @@ public static void createDeleteMessagesAlert(BaseFragment fragment, TLRPC.User u
});
}
if (checks[2]) {
if (userFinal != null)
MessagesController.getInstance(currentAccount).deleteUserChannelHistory(chat, userFinal, 0);
else
MessagesController.getInstance(currentAccount).deleteChannelUserChatHistory(chat, chatFinal, 0);
MessagesController.getInstance(currentAccount).deleteUserChannelHistory(chat, userFinal, chatFinal, 0);
}
}
if (onDelete != null) {
@@ -142,7 +142,7 @@ public void onItemClick(int id) {
TLRPC.Chat chat = getMessagesController().getChat(peer.channel_id);
if (!chat.broadcast) {
if (ChatObject.isChannel(chat) && chat.megagroup && ChatObject.canUserDoAction(chat, ChatObject.ACTION_DELETE_MESSAGES)) {
getMessagesController().deleteUserChannelHistory(chat, UserConfig.getInstance(currentAccount).getCurrentUser(), 0);
getMessagesController().deleteUserChannelHistory(chat, UserConfig.getInstance(currentAccount).getCurrentUser(), null, 0);
} else {
MessageHelper.getInstance(currentAccount).deleteUserChannelHistoryWithSearch(null, TLdialog.id, getMessagesController().getUser(getUserConfig().clientUserId));
}

0 comments on commit 00f7b2c

Please sign in to comment.