mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-04 02:28:03 +01:00
Revert "Chat List: Fix leaving legacy and private chats (#1235)"
This reverts commit 3d0369a002
.
This commit is contained in:
parent
4e74048a2c
commit
00f6b096a2
@ -475,28 +475,6 @@ export function joinChannel({
|
||||
}), true);
|
||||
}
|
||||
|
||||
export function deleteChatUser({
|
||||
chatId, user,
|
||||
}: {
|
||||
chatId: number; user?: ApiUser;
|
||||
}) {
|
||||
const userId = user ? buildInputEntity(user.id, user.accessHash) as GramJs.InputUser : new GramJs.InputUserSelf();
|
||||
return invokeRequest(new GramJs.messages.DeleteChatUser({
|
||||
chatId: buildInputEntity(chatId) as number,
|
||||
userId,
|
||||
}), true);
|
||||
}
|
||||
|
||||
export function deleteChat({
|
||||
chatId,
|
||||
}: {
|
||||
chatId: number;
|
||||
}) {
|
||||
return invokeRequest(new GramJs.messages.DeleteChat({
|
||||
chatId: buildInputEntity(chatId) as number,
|
||||
}), true);
|
||||
}
|
||||
|
||||
export function leaveChannel({
|
||||
channelId, accessHash,
|
||||
}: {
|
||||
|
@ -9,7 +9,7 @@ export {
|
||||
export {
|
||||
fetchChats, fetchFullChat, searchChats, requestChatUpdate,
|
||||
saveDraft, clearDraft, fetchChat, updateChatMutedState,
|
||||
createChannel, joinChannel, deleteChatUser, deleteChat, leaveChannel, deleteChannel, createGroupChat, editChatPhoto,
|
||||
createChannel, joinChannel, leaveChannel, deleteChannel, createGroupChat, editChatPhoto,
|
||||
toggleChatPinned, toggleChatArchived, toggleDialogUnread,
|
||||
fetchChatFolders, editChatFolder, deleteChatFolder, fetchRecommendedChatFolders,
|
||||
getChatByUsername, togglePreHistoryHidden, updateChatDefaultBannedRights, updateChatMemberBannedRights,
|
||||
|
@ -41,7 +41,7 @@ type StateProps = {
|
||||
contactName?: string;
|
||||
};
|
||||
|
||||
type DispatchProps = Pick<GlobalActions, 'leaveChannel' | 'deleteHistory' | 'deleteChannel' | 'deleteChatUser'>;
|
||||
type DispatchProps = Pick<GlobalActions, 'leaveChannel' | 'deleteHistory' | 'deleteChannel'>;
|
||||
|
||||
const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
isOpen,
|
||||
@ -58,7 +58,6 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
leaveChannel,
|
||||
deleteHistory,
|
||||
deleteChannel,
|
||||
deleteChatUser,
|
||||
}) => {
|
||||
const lang = useLang();
|
||||
const chatTitle = getChatTitle(lang, chat);
|
||||
@ -70,10 +69,7 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
}, [deleteHistory, chat.id, onClose]);
|
||||
|
||||
const handleDeleteChat = useCallback(() => {
|
||||
if (isPrivateChat) {
|
||||
deleteHistory({ chatId: chat.id, shouldDeleteForAll: false });
|
||||
} else if (isBasicGroup) {
|
||||
deleteChatUser({ chatId: chat.id });
|
||||
if (isPrivateChat || isBasicGroup) {
|
||||
deleteHistory({ chatId: chat.id, shouldDeleteForAll: false });
|
||||
} else if ((isChannel || isSuperGroup) && !chat.isCreator) {
|
||||
leaveChannel({ chatId: chat.id });
|
||||
@ -90,7 +86,6 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
chat.id,
|
||||
onClose,
|
||||
deleteHistory,
|
||||
deleteChatUser,
|
||||
leaveChannel,
|
||||
deleteChannel,
|
||||
]);
|
||||
@ -192,6 +187,5 @@ export default memo(withGlobal<OwnProps>(
|
||||
contactName,
|
||||
};
|
||||
},
|
||||
(setGlobal, actions): DispatchProps => pick(actions,
|
||||
['leaveChannel', 'deleteHistory', 'deleteChannel', 'deleteChatUser']),
|
||||
(setGlobal, actions): DispatchProps => pick(actions, ['leaveChannel', 'deleteHistory', 'deleteChannel']),
|
||||
)(DeleteChatModal));
|
||||
|
@ -43,7 +43,7 @@ type StateProps = {
|
||||
|
||||
type DispatchProps = Pick<GlobalActions, (
|
||||
'togglePreHistoryHidden' | 'updateChat' | 'closeManagement' |
|
||||
'leaveChannel' | 'deleteChannel' | 'deleteChat' | 'openChat'
|
||||
'deleteHistory' | 'leaveChannel' | 'deleteChannel' | 'openChat'
|
||||
)>;
|
||||
|
||||
const GROUP_TITLE_EMPTY = 'Group title can\'t be empty';
|
||||
@ -63,7 +63,7 @@ const ManageGroup: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
onScreenSelect,
|
||||
togglePreHistoryHidden,
|
||||
updateChat,
|
||||
deleteChat,
|
||||
deleteHistory,
|
||||
leaveChannel,
|
||||
deleteChannel,
|
||||
closeManagement,
|
||||
@ -182,7 +182,7 @@ const ManageGroup: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
|
||||
const handleDeleteGroup = useCallback(() => {
|
||||
if (isBasicGroup) {
|
||||
deleteChat({ chatId: chat.id });
|
||||
deleteHistory({ chatId: chat.id, shouldDeleteForAll: false });
|
||||
} else if (!chat.isCreator) {
|
||||
leaveChannel({ chatId: chat.id });
|
||||
} else {
|
||||
@ -193,7 +193,7 @@ const ManageGroup: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
openChat({ id: undefined });
|
||||
}, [
|
||||
isBasicGroup, chat.isCreator, chat.id,
|
||||
closeDeleteDialog, closeManagement, leaveChannel, deleteChannel, deleteChat, openChat,
|
||||
closeDeleteDialog, closeManagement, deleteHistory, leaveChannel, deleteChannel, openChat,
|
||||
]);
|
||||
|
||||
if (chat.isRestricted) {
|
||||
@ -325,6 +325,6 @@ export default memo(withGlobal<OwnProps>(
|
||||
},
|
||||
(setGlobal, actions): DispatchProps => pick(actions, [
|
||||
'togglePreHistoryHidden', 'updateChat', 'closeManagement',
|
||||
'leaveChannel', 'deleteChannel', 'deleteChat', 'openChat',
|
||||
'deleteHistory', 'leaveChannel', 'deleteChannel', 'openChat',
|
||||
]),
|
||||
)(ManageGroup));
|
||||
|
@ -421,7 +421,7 @@ export type ActionTypes = (
|
||||
'editMessage' | 'deleteHistory' | 'enterMessageSelectMode' | 'toggleMessageSelection' | 'exitMessageSelectMode' |
|
||||
'openTelegramLink' | 'openChatByUsername' | 'requestThreadInfoUpdate' | 'setScrollOffset' | 'unpinAllMessages' |
|
||||
'setReplyingToId' | 'setEditingId' | 'editLastMessage' | 'saveDraft' | 'clearDraft' | 'loadPinnedMessages' |
|
||||
'loadMessageLink' | 'toggleMessageWebPage' | 'replyToNextMessage' | 'deleteChatUser' | 'deleteChat' |
|
||||
'loadMessageLink' | 'toggleMessageWebPage' | 'replyToNextMessage' |
|
||||
// scheduled messages
|
||||
'loadScheduledHistory' | 'sendScheduledMessages' | 'rescheduleMessage' | 'deleteScheduledMessages' |
|
||||
// poll result
|
||||
|
@ -971,7 +971,6 @@ messages.getChats#3c6aa187 id:Vector<int> = messages.Chats;
|
||||
messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull;
|
||||
messages.editChatTitle#dc452855 chat_id:int title:string = Updates;
|
||||
messages.editChatPhoto#ca4c79d8 chat_id:int photo:InputChatPhoto = Updates;
|
||||
messages.deleteChatUser#c534459a flags:# revoke_history:flags.0?true chat_id:int user_id:InputUser = Updates;
|
||||
messages.createChat#9cb126e users:Vector<InputUser> title:string = Updates;
|
||||
messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig;
|
||||
messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages;
|
||||
@ -1022,7 +1021,6 @@ messages.getReplies#24b581ba peer:InputPeer msg_id:int offset_id:int offset_date
|
||||
messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
|
||||
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
||||
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
||||
messages.deleteChat#83247d11 chat_id:int = Bool;
|
||||
updates.getState#edd4882a = updates.State;
|
||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
||||
updates.getChannelDifference#3173d78 flags:# force:flags.0?true channel:InputChannel filter:ChannelMessagesFilter pts:int limit:int = updates.ChannelDifference;
|
||||
|
@ -971,7 +971,6 @@ messages.getChats#3c6aa187 id:Vector<int> = messages.Chats;
|
||||
messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull;
|
||||
messages.editChatTitle#dc452855 chat_id:int title:string = Updates;
|
||||
messages.editChatPhoto#ca4c79d8 chat_id:int photo:InputChatPhoto = Updates;
|
||||
messages.deleteChatUser#c534459a flags:# revoke_history:flags.0?true chat_id:int user_id:InputUser = Updates;
|
||||
messages.createChat#9cb126e users:Vector<InputUser> title:string = Updates;
|
||||
messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig;
|
||||
messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages;
|
||||
@ -1022,7 +1021,6 @@ messages.getReplies#24b581ba peer:InputPeer msg_id:int offset_id:int offset_date
|
||||
messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
|
||||
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
||||
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
||||
messages.deleteChat#83247d11 chat_id:int = Bool;
|
||||
updates.getState#edd4882a = updates.State;
|
||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
||||
updates.getChannelDifference#3173d78 flags:# force:flags.0?true channel:InputChannel filter:ChannelMessagesFilter pts:int limit:int = updates.ChannelDifference;
|
||||
|
@ -228,35 +228,6 @@ addReducer('joinChannel', (global, actions, payload) => {
|
||||
}
|
||||
});
|
||||
|
||||
addReducer('deleteChatUser', (global, actions, payload) => {
|
||||
(async () => {
|
||||
const { chatId, userId } : {chatId: number; userId?: number} = payload!;
|
||||
const chat = selectChat(global, chatId);
|
||||
if (!chat) {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = userId !== undefined ? selectUser(global, userId) : undefined;
|
||||
await callApi('deleteChatUser', { chatId: chat.id, user });
|
||||
|
||||
actions.openChat({ id: undefined });
|
||||
})();
|
||||
});
|
||||
|
||||
addReducer('deleteChat', (global, actions, payload) => {
|
||||
(async () => {
|
||||
const { chatId } : {chatId: number } = payload!;
|
||||
const chat = selectChat(global, chatId);
|
||||
|
||||
if (!chat) {
|
||||
return;
|
||||
}
|
||||
await callApi('deleteChat', { chatId: chat.id });
|
||||
|
||||
actions.openChat({ id: undefined });
|
||||
})();
|
||||
});
|
||||
|
||||
addReducer('leaveChannel', (global, actions, payload) => {
|
||||
(async () => {
|
||||
const { chatId } = payload!;
|
||||
|
Loading…
Reference in New Issue
Block a user