Removed MTP::Error from migrating chat.
This commit is contained in:
		
							parent
							
								
									0dfb77435d
								
							
						
					
					
						commit
						d218b76efe
					
				
					 3 changed files with 12 additions and 13 deletions
				
			
		|  | @ -1024,7 +1024,7 @@ void ApiWrap::requestFullPeer(not_null<PeerData*> peer) { | ||||||
| 	const auto requestId = [&] { | 	const auto requestId = [&] { | ||||||
| 		const auto failHandler = [=](const MTP::Error &error) { | 		const auto failHandler = [=](const MTP::Error &error) { | ||||||
| 			_fullPeerRequests.remove(peer); | 			_fullPeerRequests.remove(peer); | ||||||
| 			migrateFail(peer, error); | 			migrateFail(peer, error.type()); | ||||||
| 		}; | 		}; | ||||||
| 		if (const auto user = peer->asUser()) { | 		if (const auto user = peer->asUser()) { | ||||||
| 			if (_session->supportMode()) { | 			if (_session->supportMode()) { | ||||||
|  | @ -1191,7 +1191,7 @@ void ApiWrap::requestPeerSettings(not_null<PeerData*> peer) { | ||||||
| void ApiWrap::migrateChat( | void ApiWrap::migrateChat( | ||||||
| 		not_null<ChatData*> chat, | 		not_null<ChatData*> chat, | ||||||
| 		FnMut<void(not_null<ChannelData*>)> done, | 		FnMut<void(not_null<ChannelData*>)> done, | ||||||
| 		Fn<void(const MTP::Error &)> fail) { | 		Fn<void(const QString &)> fail) { | ||||||
| 	const auto callback = [&] { | 	const auto callback = [&] { | ||||||
| 		return MigrateCallbacks{ std::move(done), std::move(fail) }; | 		return MigrateCallbacks{ std::move(done), std::move(fail) }; | ||||||
| 	}; | 	}; | ||||||
|  | @ -1214,7 +1214,7 @@ void ApiWrap::migrateChat( | ||||||
| 				chat, | 				chat, | ||||||
| 				MTP::Error::Local( | 				MTP::Error::Local( | ||||||
| 					"BAD_MIGRATION", | 					"BAD_MIGRATION", | ||||||
| 					"Chat is already deactivated")); | 					"Chat is already deactivated").type()); | ||||||
| 		}); | 		}); | ||||||
| 		return; | 		return; | ||||||
| 	} else if (!chat->amCreator()) { | 	} else if (!chat->amCreator()) { | ||||||
|  | @ -1223,7 +1223,7 @@ void ApiWrap::migrateChat( | ||||||
| 				chat, | 				chat, | ||||||
| 				MTP::Error::Local( | 				MTP::Error::Local( | ||||||
| 					"BAD_MIGRATION", | 					"BAD_MIGRATION", | ||||||
| 					"Current user is not the creator of that chat")); | 					"Current user is not the creator of that chat").type()); | ||||||
| 		}); | 		}); | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
|  | @ -1242,10 +1242,10 @@ void ApiWrap::migrateChat( | ||||||
| 		} else { | 		} else { | ||||||
| 			migrateFail( | 			migrateFail( | ||||||
| 				chat, | 				chat, | ||||||
| 				MTP::Error::Local("MIGRATION_FAIL", "No channel")); | 				MTP::Error::Local("MIGRATION_FAIL", "No channel").type()); | ||||||
| 		} | 		} | ||||||
| 	}).fail([=](const MTP::Error &error) { | 	}).fail([=](const MTP::Error &error) { | ||||||
| 		migrateFail(chat, error); | 		migrateFail(chat, error.type()); | ||||||
| 	}).send(); | 	}).send(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -1262,9 +1262,8 @@ void ApiWrap::migrateDone( | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ApiWrap::migrateFail(not_null<PeerData*> peer, const MTP::Error &error) { | void ApiWrap::migrateFail(not_null<PeerData*> peer, const QString &error) { | ||||||
| 	const auto &type = error.type(); | 	if (error == u"CHANNELS_TOO_MUCH"_q) { | ||||||
| 	if (type == qstr("CHANNELS_TOO_MUCH")) { |  | ||||||
| 		Ui::show(Box<Ui::InformBox>(tr::lng_migrate_error(tr::now))); | 		Ui::show(Box<Ui::InformBox>(tr::lng_migrate_error(tr::now))); | ||||||
| 	} | 	} | ||||||
| 	if (auto handlers = _migrateCallbacks.take(peer)) { | 	if (auto handlers = _migrateCallbacks.take(peer)) { | ||||||
|  |  | ||||||
|  | @ -208,7 +208,7 @@ public: | ||||||
| 	void migrateChat( | 	void migrateChat( | ||||||
| 		not_null<ChatData*> chat, | 		not_null<ChatData*> chat, | ||||||
| 		FnMut<void(not_null<ChannelData*>)> done, | 		FnMut<void(not_null<ChannelData*>)> done, | ||||||
| 		Fn<void(const MTP::Error &)> fail = nullptr); | 		Fn<void(const QString &)> fail = nullptr); | ||||||
| 
 | 
 | ||||||
| 	void markMediaRead(const base::flat_set<not_null<HistoryItem*>> &items); | 	void markMediaRead(const base::flat_set<not_null<HistoryItem*>> &items); | ||||||
| 	void markMediaRead(not_null<HistoryItem*> item); | 	void markMediaRead(not_null<HistoryItem*> item); | ||||||
|  | @ -512,7 +512,7 @@ private: | ||||||
| 	void migrateDone( | 	void migrateDone( | ||||||
| 		not_null<PeerData*> peer, | 		not_null<PeerData*> peer, | ||||||
| 		not_null<ChannelData*> channel); | 		not_null<ChannelData*> channel); | ||||||
| 	void migrateFail(not_null<PeerData*> peer, const MTP::Error &error); | 	void migrateFail(not_null<PeerData*> peer, const QString &error); | ||||||
| 
 | 
 | ||||||
| 	not_null<Main::Session*> _session; | 	not_null<Main::Session*> _session; | ||||||
| 
 | 
 | ||||||
|  | @ -613,7 +613,7 @@ private: | ||||||
| 
 | 
 | ||||||
| 	struct MigrateCallbacks { | 	struct MigrateCallbacks { | ||||||
| 		FnMut<void(not_null<ChannelData*>)> done; | 		FnMut<void(not_null<ChannelData*>)> done; | ||||||
| 		Fn<void(const MTP::Error&)> fail; | 		Fn<void(const QString&)> fail; | ||||||
| 	}; | 	}; | ||||||
| 	base::flat_map< | 	base::flat_map< | ||||||
| 		not_null<PeerData*>, | 		not_null<PeerData*>, | ||||||
|  |  | ||||||
|  | @ -242,7 +242,7 @@ void ShowEditPermissions( | ||||||
| 		const auto api = &peer->session().api(); | 		const auto api = &peer->session().api(); | ||||||
| 		api->migrateChat(chat, [=](not_null<ChannelData*> channel) { | 		api->migrateChat(chat, [=](not_null<ChannelData*> channel) { | ||||||
| 			save(channel, result); | 			save(channel, result); | ||||||
| 		}, [=](const MTP::Error &) { | 		}, [=](const QString &) { | ||||||
| 			*saving = false; | 			*saving = false; | ||||||
| 		}); | 		}); | ||||||
| 	}, box->lifetime()); | 	}, box->lifetime()); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 23rd
						23rd