mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
fixed delete chat where you are not participant / deactivated chat, scheme updated
This commit is contained in:
parent
1fa4fd269e
commit
583c0e5904
10 changed files with 45 additions and 35 deletions
|
@ -178,6 +178,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
|||
"lng_contacts_loading" = "Loading..";
|
||||
"lng_contacts_not_found" = "No contacts found";
|
||||
"lng_dlg_search_chat" = "Search in this chat";
|
||||
"lng_dlg_search_channel" = "Search in this channel";
|
||||
"lng_dlg_search_for_messages" = "Search for messages";
|
||||
|
||||
"lng_settings_save" = "Save";
|
||||
|
@ -477,7 +478,7 @@ Copyright (c) 2014-2015 John Preston, https://desktop.telegram.org
|
|||
"lng_sure_delete_and_exit" = "Are you sure, you want to delete all message history and leave «{group}»?\n\nThis action cannot be undone.";
|
||||
"lng_sure_leave_channel" = "Are you sure, you want to leave\nthis channel?";
|
||||
"lng_sure_delete_channel" = "Are you sure, you want to delete this channel? All members will be removed and all messages will be lost.";
|
||||
"lng_sure_leave_group" = "Are you sure, you want to leave\nthis group?";
|
||||
"lng_sure_leave_group" = "Are you sure, you want to leave\nthis group? This action cannot be undone.";
|
||||
"lng_sure_delete_group" = "Are you sure, you want to delete this group? All members will be removed and all messages will be lost.";
|
||||
|
||||
"lng_message_empty" = "Empty Message";
|
||||
|
|
|
@ -570,11 +570,11 @@ namespace App {
|
|||
cdata->setName(qs(d.vtitle), uname);
|
||||
|
||||
cdata->access = d.vaccess_hash.v;
|
||||
cdata->setPhoto(d.vphoto);
|
||||
cdata->date = d.vdate.v;
|
||||
cdata->flags = d.vflags.v;
|
||||
cdata->isForbidden = false;
|
||||
cdata->flagsUpdated();
|
||||
cdata->setPhoto(d.vphoto);
|
||||
if (cdata->version < d.vversion.v) {
|
||||
cdata->version = d.vversion.v;
|
||||
}
|
||||
|
|
|
@ -249,7 +249,8 @@ void ContactsInner::onAllAdminsChanged() {
|
|||
update();
|
||||
}
|
||||
|
||||
void ContactsInner::addAdminDone(const MTPBool &result, mtpRequestId req) {
|
||||
void ContactsInner::addAdminDone(const MTPUpdates &result, mtpRequestId req) {
|
||||
if (App::main()) App::main()->sentUpdatesReceived(result);
|
||||
if (req != _addAdminRequestId) return;
|
||||
|
||||
_addAdminRequestId = 0;
|
||||
|
@ -2191,8 +2192,9 @@ void MembersInner::kickDone(const MTPUpdates &result, mtpRequestId req) {
|
|||
if (_kickBox) _kickBox->onClose();
|
||||
}
|
||||
|
||||
void MembersInner::kickAdminDone(const MTPBool &result, mtpRequestId req) {
|
||||
void MembersInner::kickAdminDone(const MTPUpdates &result, mtpRequestId req) {
|
||||
if (_kickRequestId != req) return;
|
||||
if (App::main()) App::main()->sentUpdatesReceived(result);
|
||||
removeKicked();
|
||||
if (_kickBox) _kickBox->onClose();
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public slots:
|
|||
private:
|
||||
|
||||
void updateSelectedRow();
|
||||
void addAdminDone(const MTPBool &result, mtpRequestId req);
|
||||
void addAdminDone(const MTPUpdates &result, mtpRequestId req);
|
||||
bool addAdminFail(const RPCError &error, mtpRequestId req);
|
||||
|
||||
int32 _rowHeight, _newItemHeight;
|
||||
|
@ -335,7 +335,7 @@ private:
|
|||
bool membersFailed(const RPCError &error, mtpRequestId req);
|
||||
|
||||
void kickDone(const MTPUpdates &result, mtpRequestId req);
|
||||
void kickAdminDone(const MTPBool &result, mtpRequestId req);
|
||||
void kickAdminDone(const MTPUpdates &result, mtpRequestId req);
|
||||
bool kickFail(const RPCError &error, mtpRequestId req);
|
||||
void removeKicked();
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ void DialogsInner::searchInPeerPaint(Painter &p, int32 w, bool onlyBackground) c
|
|||
QRect tr(nameleft, st::dlgPaddingVer + st::dlgFont->height + st::dlgSep, namewidth, st::dlgFont->height);
|
||||
p.setFont(st::dlgHistFont->f);
|
||||
p.setPen(st::dlgTextColor->p);
|
||||
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->elided(lang(lng_dlg_search_chat), tr.width()));
|
||||
p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->elided(lang((_searchInPeer->isChannel() && !_searchInPeer->isMegagroup()) ? lng_dlg_search_channel : lng_dlg_search_chat), tr.width()));
|
||||
|
||||
p.setPen(st::dlgNameColor->p);
|
||||
_searchInPeer->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
|
||||
|
|
|
@ -860,7 +860,7 @@ DragState MainWidget::getDragState(const QMimeData *mime) {
|
|||
bool MainWidget::leaveChatFailed(PeerData *peer, const RPCError &error) {
|
||||
if (mtpIsFlood(error)) return false;
|
||||
|
||||
if (error.type() == qstr("USER_NOT_PARTICIPANT") || error.type() == qstr("CHAT_ID_INVALID")) { // left this chat already
|
||||
if (error.type() == qstr("USER_NOT_PARTICIPANT") || error.type() == qstr("CHAT_ID_INVALID") || error.type() == qstr("PEER_ID_INVALID")) { // left this chat already
|
||||
deleteConversation(peer);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4816,7 +4816,8 @@ void _serialize_channelMessagesFilter(MTPStringLogger &to, int32 stage, int32 le
|
|||
switch (stage) {
|
||||
case 0: to.add(" flags: "); ++stages.back(); if (start >= end) throw Exception("start >= end in flags"); else flags.back() = *start; types.push_back(mtpc_int); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 1: to.add(" important_only: "); ++stages.back(); if (flag & MTPDchannelMessagesFilter::flag_important_only) { to.add("YES [ BY BIT 0 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 0 IN FIELD flags ]"); } break;
|
||||
case 2: to.add(" ranges: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 2: to.add(" exclude_new_messages: "); ++stages.back(); if (flag & MTPDchannelMessagesFilter::flag_exclude_new_messages) { to.add("YES [ BY BIT 1 IN FIELD flags ]"); } else { to.add("[ SKIPPED BY BIT 1 IN FIELD flags ]"); } break;
|
||||
case 3: to.add(" ranges: "); ++stages.back(); types.push_back(00); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
|
||||
}
|
||||
}
|
||||
|
@ -5543,21 +5544,6 @@ void _serialize_channels_editAbout(MTPStringLogger &to, int32 stage, int32 lev,
|
|||
}
|
||||
}
|
||||
|
||||
void _serialize_channels_editAdmin(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
|
||||
if (stage) {
|
||||
to.add(",\n").addSpaces(lev);
|
||||
} else {
|
||||
to.add("{ channels_editAdmin");
|
||||
to.add("\n").addSpaces(lev);
|
||||
}
|
||||
switch (stage) {
|
||||
case 0: to.add(" channel: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 1: to.add(" user_id: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 2: to.add(" role: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
|
||||
}
|
||||
}
|
||||
|
||||
void _serialize_channels_checkUsername(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
|
||||
if (stage) {
|
||||
to.add(",\n").addSpaces(lev);
|
||||
|
@ -6534,6 +6520,21 @@ void _serialize_channels_createChannel(MTPStringLogger &to, int32 stage, int32 l
|
|||
}
|
||||
}
|
||||
|
||||
void _serialize_channels_editAdmin(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
|
||||
if (stage) {
|
||||
to.add(",\n").addSpaces(lev);
|
||||
} else {
|
||||
to.add("{ channels_editAdmin");
|
||||
to.add("\n").addSpaces(lev);
|
||||
}
|
||||
switch (stage) {
|
||||
case 0: to.add(" channel: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 1: to.add(" user_id: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
case 2: to.add(" role: "); ++stages.back(); types.push_back(0); vtypes.push_back(0); stages.push_back(0); flags.push_back(0); break;
|
||||
default: to.add("}"); types.pop_back(); vtypes.pop_back(); stages.pop_back(); flags.pop_back(); break;
|
||||
}
|
||||
}
|
||||
|
||||
void _serialize_channels_editTitle(MTPStringLogger &to, int32 stage, int32 lev, Types &types, Types &vtypes, StagesFlags &stages, StagesFlags &flags, const mtpPrime *start, const mtpPrime *end, int32 flag) {
|
||||
if (stage) {
|
||||
to.add(",\n").addSpaces(lev);
|
||||
|
@ -7579,7 +7580,6 @@ namespace {
|
|||
_serializers.insert(mtpc_channels_readHistory, _serialize_channels_readHistory);
|
||||
_serializers.insert(mtpc_channels_reportSpam, _serialize_channels_reportSpam);
|
||||
_serializers.insert(mtpc_channels_editAbout, _serialize_channels_editAbout);
|
||||
_serializers.insert(mtpc_channels_editAdmin, _serialize_channels_editAdmin);
|
||||
_serializers.insert(mtpc_channels_checkUsername, _serialize_channels_checkUsername);
|
||||
_serializers.insert(mtpc_channels_updateUsername, _serialize_channels_updateUsername);
|
||||
_serializers.insert(mtpc_invokeAfterMsg, _serialize_invokeAfterMsg);
|
||||
|
@ -7652,6 +7652,7 @@ namespace {
|
|||
_serializers.insert(mtpc_messages_toggleChatAdmins, _serialize_messages_toggleChatAdmins);
|
||||
_serializers.insert(mtpc_messages_migrateChat, _serialize_messages_migrateChat);
|
||||
_serializers.insert(mtpc_channels_createChannel, _serialize_channels_createChannel);
|
||||
_serializers.insert(mtpc_channels_editAdmin, _serialize_channels_editAdmin);
|
||||
_serializers.insert(mtpc_channels_editTitle, _serialize_channels_editTitle);
|
||||
_serializers.insert(mtpc_channels_editPhoto, _serialize_channels_editPhoto);
|
||||
_serializers.insert(mtpc_channels_toggleComments, _serialize_channels_toggleComments);
|
||||
|
|
|
@ -573,7 +573,7 @@ enum {
|
|||
mtpc_channels_getFullChannel = 0x8736a09,
|
||||
mtpc_channels_createChannel = 0xf4893d7f,
|
||||
mtpc_channels_editAbout = 0x13e27f1e,
|
||||
mtpc_channels_editAdmin = 0x52b16962,
|
||||
mtpc_channels_editAdmin = 0xeb7611d0,
|
||||
mtpc_channels_editTitle = 0x566decd0,
|
||||
mtpc_channels_editPhoto = 0xf12e57c9,
|
||||
mtpc_channels_toggleComments = 0xaaa29e88,
|
||||
|
@ -12597,9 +12597,11 @@ public:
|
|||
|
||||
enum {
|
||||
flag_important_only = (1 << 0),
|
||||
flag_exclude_new_messages = (1 << 1),
|
||||
};
|
||||
|
||||
bool is_important_only() const { return vflags.v & flag_important_only; }
|
||||
bool is_exclude_new_messages() const { return vflags.v & flag_exclude_new_messages; }
|
||||
};
|
||||
|
||||
class MTPDchannelParticipant : public mtpDataImpl<MTPDchannelParticipant> {
|
||||
|
@ -18872,7 +18874,7 @@ public:
|
|||
vrole.write(to);
|
||||
}
|
||||
|
||||
typedef MTPBool ResponseType;
|
||||
typedef MTPUpdates ResponseType;
|
||||
};
|
||||
class MTPchannels_EditAdmin : public MTPBoxed<MTPchannels_editAdmin> {
|
||||
public:
|
||||
|
|
|
@ -602,7 +602,7 @@ updates.channelDifferenceTooLong#5e167646 flags:# final:flags.0?true pts:int tim
|
|||
updates.channelDifference#2064674e flags:# final:flags.0?true pts:int timeout:flags.1?int new_messages:Vector<Message> other_updates:Vector<Update> chats:Vector<Chat> users:Vector<User> = updates.ChannelDifference;
|
||||
|
||||
channelMessagesFilterEmpty#94d42ee7 = ChannelMessagesFilter;
|
||||
channelMessagesFilter#cd77d957 flags:# important_only:flags.0?true ranges:Vector<MessageRange> = ChannelMessagesFilter;
|
||||
channelMessagesFilter#cd77d957 flags:# important_only:flags.0?true exclude_new_messages:flags.1?true ranges:Vector<MessageRange> = ChannelMessagesFilter;
|
||||
channelMessagesFilterCollapsed#fa01232e = ChannelMessagesFilter;
|
||||
|
||||
channelParticipant#15ebac1d user_id:int date:int = ChannelParticipant;
|
||||
|
@ -774,7 +774,7 @@ channels.getChannels#a7f6bbb id:Vector<InputChannel> = messages.Chats;
|
|||
channels.getFullChannel#8736a09 channel:InputChannel = messages.ChatFull;
|
||||
channels.createChannel#f4893d7f flags:# broadcast:flags.0?true megagroup:flags.1?true title:string about:string = Updates;
|
||||
channels.editAbout#13e27f1e channel:InputChannel about:string = Bool;
|
||||
channels.editAdmin#52b16962 channel:InputChannel user_id:InputUser role:ChannelParticipantRole = Bool;
|
||||
channels.editAdmin#eb7611d0 channel:InputChannel user_id:InputUser role:ChannelParticipantRole = Updates;
|
||||
channels.editTitle#566decd0 channel:InputChannel title:string = Updates;
|
||||
channels.editPhoto#f12e57c9 channel:InputChannel photo:InputChatPhoto = Updates;
|
||||
channels.toggleComments#aaa29e88 channel:InputChannel enabled:Bool = Updates;
|
||||
|
|
|
@ -331,6 +331,9 @@ void ProfileInner::onDeleteConversationSure() {
|
|||
} else if (_peerChannel) {
|
||||
App::wnd()->hideLayer();
|
||||
App::main()->showDialogs();
|
||||
if (_peerChannel->migrateFrom()) {
|
||||
App::main()->deleteConversation(_peerChannel->migrateFrom());
|
||||
}
|
||||
MTP::send(MTPchannels_LeaveChannel(_peerChannel->inputChannel), App::main()->rpcDone(&MainWidget::sentUpdatesReceived));
|
||||
}
|
||||
}
|
||||
|
@ -346,6 +349,9 @@ void ProfileInner::onDeleteChannelSure() {
|
|||
if (_peerChannel) {
|
||||
App::wnd()->hideLayer();
|
||||
App::main()->showDialogs();
|
||||
if (_peerChannel->migrateFrom()) {
|
||||
App::main()->deleteConversation(_peerChannel->migrateFrom());
|
||||
}
|
||||
MTP::send(MTPchannels_DeleteChannel(_peerChannel->inputChannel), App::main()->rpcDone(&MainWidget::sentUpdatesReceived));
|
||||
}
|
||||
}
|
||||
|
@ -801,14 +807,10 @@ void ProfileInner::paintEvent(QPaintEvent *e) {
|
|||
top += st::profilePhotoSize;
|
||||
top += st::profileButtonTop;
|
||||
|
||||
if (_peerChat && !_peerChat->amIn()) {
|
||||
int32 w = st::btnShareContact.font->width(lang(lng_profile_chat_unaccessible));
|
||||
p.setFont(st::btnShareContact.font->f);
|
||||
p.setPen(st::profileOfflineColor->p);
|
||||
p.drawText(_left + (_width - w) / 2, top + st::btnShareContact.textTop + st::btnShareContact.font->ascent, lang(lng_profile_chat_unaccessible));
|
||||
}
|
||||
if ((!_peerChat || _peerChat->canEdit()) && (!_peerChannel || _amCreator || (_peerChannel->amEditor() && _peerChannel->isMegagroup()))) {
|
||||
top += _shareContact.height();
|
||||
} else {
|
||||
top -= st::profileButtonTop;
|
||||
}
|
||||
|
||||
// about
|
||||
|
@ -1276,6 +1278,8 @@ void ProfileInner::resizeEvent(QResizeEvent *e) {
|
|||
|
||||
if ((!_peerChat || _peerChat->canEdit()) && (!_peerChannel || _amCreator || (_peerChannel->amEditor() && _peerChannel->isMegagroup()))) {
|
||||
top += _shareContact.height();
|
||||
} else {
|
||||
top -= st::profileButtonTop;
|
||||
}
|
||||
|
||||
// about
|
||||
|
|
Loading…
Add table
Reference in a new issue