mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-04 10:40:09 +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);
|
}), 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({
|
export function leaveChannel({
|
||||||
channelId, accessHash,
|
channelId, accessHash,
|
||||||
}: {
|
}: {
|
||||||
|
@ -9,7 +9,7 @@ export {
|
|||||||
export {
|
export {
|
||||||
fetchChats, fetchFullChat, searchChats, requestChatUpdate,
|
fetchChats, fetchFullChat, searchChats, requestChatUpdate,
|
||||||
saveDraft, clearDraft, fetchChat, updateChatMutedState,
|
saveDraft, clearDraft, fetchChat, updateChatMutedState,
|
||||||
createChannel, joinChannel, deleteChatUser, deleteChat, leaveChannel, deleteChannel, createGroupChat, editChatPhoto,
|
createChannel, joinChannel, leaveChannel, deleteChannel, createGroupChat, editChatPhoto,
|
||||||
toggleChatPinned, toggleChatArchived, toggleDialogUnread,
|
toggleChatPinned, toggleChatArchived, toggleDialogUnread,
|
||||||
fetchChatFolders, editChatFolder, deleteChatFolder, fetchRecommendedChatFolders,
|
fetchChatFolders, editChatFolder, deleteChatFolder, fetchRecommendedChatFolders,
|
||||||
getChatByUsername, togglePreHistoryHidden, updateChatDefaultBannedRights, updateChatMemberBannedRights,
|
getChatByUsername, togglePreHistoryHidden, updateChatDefaultBannedRights, updateChatMemberBannedRights,
|
||||||
|
@ -41,7 +41,7 @@ type StateProps = {
|
|||||||
contactName?: string;
|
contactName?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DispatchProps = Pick<GlobalActions, 'leaveChannel' | 'deleteHistory' | 'deleteChannel' | 'deleteChatUser'>;
|
type DispatchProps = Pick<GlobalActions, 'leaveChannel' | 'deleteHistory' | 'deleteChannel'>;
|
||||||
|
|
||||||
const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
@ -58,7 +58,6 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
leaveChannel,
|
leaveChannel,
|
||||||
deleteHistory,
|
deleteHistory,
|
||||||
deleteChannel,
|
deleteChannel,
|
||||||
deleteChatUser,
|
|
||||||
}) => {
|
}) => {
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
const chatTitle = getChatTitle(lang, chat);
|
const chatTitle = getChatTitle(lang, chat);
|
||||||
@ -70,10 +69,7 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
}, [deleteHistory, chat.id, onClose]);
|
}, [deleteHistory, chat.id, onClose]);
|
||||||
|
|
||||||
const handleDeleteChat = useCallback(() => {
|
const handleDeleteChat = useCallback(() => {
|
||||||
if (isPrivateChat) {
|
if (isPrivateChat || isBasicGroup) {
|
||||||
deleteHistory({ chatId: chat.id, shouldDeleteForAll: false });
|
|
||||||
} else if (isBasicGroup) {
|
|
||||||
deleteChatUser({ chatId: chat.id });
|
|
||||||
deleteHistory({ chatId: chat.id, shouldDeleteForAll: false });
|
deleteHistory({ chatId: chat.id, shouldDeleteForAll: false });
|
||||||
} else if ((isChannel || isSuperGroup) && !chat.isCreator) {
|
} else if ((isChannel || isSuperGroup) && !chat.isCreator) {
|
||||||
leaveChannel({ chatId: chat.id });
|
leaveChannel({ chatId: chat.id });
|
||||||
@ -90,7 +86,6 @@ const DeleteChatModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
chat.id,
|
chat.id,
|
||||||
onClose,
|
onClose,
|
||||||
deleteHistory,
|
deleteHistory,
|
||||||
deleteChatUser,
|
|
||||||
leaveChannel,
|
leaveChannel,
|
||||||
deleteChannel,
|
deleteChannel,
|
||||||
]);
|
]);
|
||||||
@ -192,6 +187,5 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
contactName,
|
contactName,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions,
|
(setGlobal, actions): DispatchProps => pick(actions, ['leaveChannel', 'deleteHistory', 'deleteChannel']),
|
||||||
['leaveChannel', 'deleteHistory', 'deleteChannel', 'deleteChatUser']),
|
|
||||||
)(DeleteChatModal));
|
)(DeleteChatModal));
|
||||||
|
@ -43,7 +43,7 @@ type StateProps = {
|
|||||||
|
|
||||||
type DispatchProps = Pick<GlobalActions, (
|
type DispatchProps = Pick<GlobalActions, (
|
||||||
'togglePreHistoryHidden' | 'updateChat' | 'closeManagement' |
|
'togglePreHistoryHidden' | 'updateChat' | 'closeManagement' |
|
||||||
'leaveChannel' | 'deleteChannel' | 'deleteChat' | 'openChat'
|
'deleteHistory' | 'leaveChannel' | 'deleteChannel' | 'openChat'
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
const GROUP_TITLE_EMPTY = 'Group title can\'t be empty';
|
const GROUP_TITLE_EMPTY = 'Group title can\'t be empty';
|
||||||
@ -63,7 +63,7 @@ const ManageGroup: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
onScreenSelect,
|
onScreenSelect,
|
||||||
togglePreHistoryHidden,
|
togglePreHistoryHidden,
|
||||||
updateChat,
|
updateChat,
|
||||||
deleteChat,
|
deleteHistory,
|
||||||
leaveChannel,
|
leaveChannel,
|
||||||
deleteChannel,
|
deleteChannel,
|
||||||
closeManagement,
|
closeManagement,
|
||||||
@ -182,7 +182,7 @@ const ManageGroup: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
|
|
||||||
const handleDeleteGroup = useCallback(() => {
|
const handleDeleteGroup = useCallback(() => {
|
||||||
if (isBasicGroup) {
|
if (isBasicGroup) {
|
||||||
deleteChat({ chatId: chat.id });
|
deleteHistory({ chatId: chat.id, shouldDeleteForAll: false });
|
||||||
} else if (!chat.isCreator) {
|
} else if (!chat.isCreator) {
|
||||||
leaveChannel({ chatId: chat.id });
|
leaveChannel({ chatId: chat.id });
|
||||||
} else {
|
} else {
|
||||||
@ -193,7 +193,7 @@ const ManageGroup: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
openChat({ id: undefined });
|
openChat({ id: undefined });
|
||||||
}, [
|
}, [
|
||||||
isBasicGroup, chat.isCreator, chat.id,
|
isBasicGroup, chat.isCreator, chat.id,
|
||||||
closeDeleteDialog, closeManagement, leaveChannel, deleteChannel, deleteChat, openChat,
|
closeDeleteDialog, closeManagement, deleteHistory, leaveChannel, deleteChannel, openChat,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (chat.isRestricted) {
|
if (chat.isRestricted) {
|
||||||
@ -325,6 +325,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
},
|
},
|
||||||
(setGlobal, actions): DispatchProps => pick(actions, [
|
(setGlobal, actions): DispatchProps => pick(actions, [
|
||||||
'togglePreHistoryHidden', 'updateChat', 'closeManagement',
|
'togglePreHistoryHidden', 'updateChat', 'closeManagement',
|
||||||
'leaveChannel', 'deleteChannel', 'deleteChat', 'openChat',
|
'deleteHistory', 'leaveChannel', 'deleteChannel', 'openChat',
|
||||||
]),
|
]),
|
||||||
)(ManageGroup));
|
)(ManageGroup));
|
||||||
|
@ -421,7 +421,7 @@ export type ActionTypes = (
|
|||||||
'editMessage' | 'deleteHistory' | 'enterMessageSelectMode' | 'toggleMessageSelection' | 'exitMessageSelectMode' |
|
'editMessage' | 'deleteHistory' | 'enterMessageSelectMode' | 'toggleMessageSelection' | 'exitMessageSelectMode' |
|
||||||
'openTelegramLink' | 'openChatByUsername' | 'requestThreadInfoUpdate' | 'setScrollOffset' | 'unpinAllMessages' |
|
'openTelegramLink' | 'openChatByUsername' | 'requestThreadInfoUpdate' | 'setScrollOffset' | 'unpinAllMessages' |
|
||||||
'setReplyingToId' | 'setEditingId' | 'editLastMessage' | 'saveDraft' | 'clearDraft' | 'loadPinnedMessages' |
|
'setReplyingToId' | 'setEditingId' | 'editLastMessage' | 'saveDraft' | 'clearDraft' | 'loadPinnedMessages' |
|
||||||
'loadMessageLink' | 'toggleMessageWebPage' | 'replyToNextMessage' | 'deleteChatUser' | 'deleteChat' |
|
'loadMessageLink' | 'toggleMessageWebPage' | 'replyToNextMessage' |
|
||||||
// scheduled messages
|
// scheduled messages
|
||||||
'loadScheduledHistory' | 'sendScheduledMessages' | 'rescheduleMessage' | 'deleteScheduledMessages' |
|
'loadScheduledHistory' | 'sendScheduledMessages' | 'rescheduleMessage' | 'deleteScheduledMessages' |
|
||||||
// poll result
|
// poll result
|
||||||
|
@ -971,7 +971,6 @@ messages.getChats#3c6aa187 id:Vector<int> = messages.Chats;
|
|||||||
messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull;
|
messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull;
|
||||||
messages.editChatTitle#dc452855 chat_id:int title:string = Updates;
|
messages.editChatTitle#dc452855 chat_id:int title:string = Updates;
|
||||||
messages.editChatPhoto#ca4c79d8 chat_id:int photo:InputChatPhoto = 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.createChat#9cb126e users:Vector<InputUser> title:string = Updates;
|
||||||
messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig;
|
messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig;
|
||||||
messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages;
|
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.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
|
||||||
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
||||||
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
||||||
messages.deleteChat#83247d11 chat_id:int = Bool;
|
|
||||||
updates.getState#edd4882a = updates.State;
|
updates.getState#edd4882a = updates.State;
|
||||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
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;
|
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.getFullChat#3b831c66 chat_id:int = messages.ChatFull;
|
||||||
messages.editChatTitle#dc452855 chat_id:int title:string = Updates;
|
messages.editChatTitle#dc452855 chat_id:int title:string = Updates;
|
||||||
messages.editChatPhoto#ca4c79d8 chat_id:int photo:InputChatPhoto = 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.createChat#9cb126e users:Vector<InputUser> title:string = Updates;
|
||||||
messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig;
|
messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig;
|
||||||
messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages;
|
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.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
|
||||||
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool;
|
||||||
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory;
|
||||||
messages.deleteChat#83247d11 chat_id:int = Bool;
|
|
||||||
updates.getState#edd4882a = updates.State;
|
updates.getState#edd4882a = updates.State;
|
||||||
updates.getDifference#25939651 flags:# pts:int pts_total_limit:flags.0?int date:int qts:int = updates.Difference;
|
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;
|
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) => {
|
addReducer('leaveChannel', (global, actions, payload) => {
|
||||||
(async () => {
|
(async () => {
|
||||||
const { chatId } = payload!;
|
const { chatId } = payload!;
|
||||||
|
Loading…
Reference in New Issue
Block a user