Use separate phrases for clearing saved messages.
This commit is contained in:
		
							parent
							
								
									c6d3fd883a
								
							
						
					
					
						commit
						775cede16f
					
				
					 7 changed files with 86 additions and 84 deletions
				
			
		|  | @ -743,6 +743,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org | |||
| "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_delete_group" = "Are you sure, you want to delete this group? All members will be removed and all messages will be lost."; | ||||
| "lng_sure_delete_saved_messages" = "Are you sure, you want to delete all your saved messages?\n\nThis action cannot be undone."; | ||||
| 
 | ||||
| "lng_message_empty" = "Empty Message"; | ||||
| "lng_message_unsupported" = "This message is not supported by your version of Telegram Desktop. Please update to the last version in Settings or install it from {link}"; | ||||
|  | @ -975,7 +976,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org | |||
| "lng_unblock_button" = "Unblock"; | ||||
| "lng_channel_mute" = "Mute"; | ||||
| "lng_channel_unmute" = "Unmute"; | ||||
| "lng_saved_messages" = "Saved messages"; | ||||
| "lng_saved_messages" = "Saved Messages"; | ||||
| "lng_saved_short" = "Saved"; | ||||
| "lng_saved_forward_here" = "Forward messages here for quick access"; | ||||
| 
 | ||||
|  |  | |||
|  | @ -524,7 +524,8 @@ void TopBar::performDelete() { | |||
| 
 | ||||
| rpl::producer<QString> TitleValue( | ||||
| 		const Section §ion, | ||||
| 		not_null<PeerData*> peer) { | ||||
| 		not_null<PeerData*> peer, | ||||
| 		bool isStackBottom) { | ||||
| 	return Lang::Viewer([&] { | ||||
| 		switch (section.type()) { | ||||
| 		case Section::Type::Profile: | ||||
|  | @ -542,6 +543,9 @@ rpl::producer<QString> TitleValue( | |||
| 			Unexpected("Bad peer type in Info::TitleValue()"); | ||||
| 
 | ||||
| 		case Section::Type::Media: | ||||
| 			if (peer->isSelf() && isStackBottom) { | ||||
| 				return lng_profile_shared_media; | ||||
| 			} | ||||
| 			switch (section.mediaType()) { | ||||
| 			case Section::MediaType::Photo: | ||||
| 				return lng_media_type_photos; | ||||
|  |  | |||
|  | @ -43,7 +43,8 @@ class Section; | |||
| 
 | ||||
| rpl::producer<QString> TitleValue( | ||||
| 	const Section §ion, | ||||
| 	not_null<PeerData*> peer); | ||||
| 	not_null<PeerData*> peer, | ||||
| 	bool isStackBottom); | ||||
| 
 | ||||
| class TopBar : public Ui::RpWidget { | ||||
| public: | ||||
|  |  | |||
|  | @ -315,7 +315,8 @@ void WrapWidget::createTopBar() { | |||
| 
 | ||||
| 	_topBar->setTitle(TitleValue( | ||||
| 		_controller->section(), | ||||
| 		_controller->peer())); | ||||
| 		_controller->peer(), | ||||
| 		!hasStackHistory())); | ||||
| 	if (wrapValue == Wrap::Narrow || hasStackHistory()) { | ||||
| 		_topBar->enableBackButton(); | ||||
| 		_topBar->backRequest() | ||||
|  |  | |||
|  | @ -453,53 +453,20 @@ void ActionsFiller::addDeleteContactAction( | |||
| } | ||||
| 
 | ||||
| void ActionsFiller::addClearHistoryAction(not_null<UserData*> user) { | ||||
| 	auto callback = [user] { | ||||
| 		auto confirmation = lng_sure_delete_history( | ||||
| 			lt_contact, | ||||
| 			App::peerName(user)); | ||||
| 		auto confirmCallback = [user] { | ||||
| 			Ui::hideLayer(); | ||||
| 			Auth().api().clearHistory(user); | ||||
| 			Ui::showPeerHistory(user, ShowAtUnreadMsgId); | ||||
| 		}; | ||||
| 		auto box = Box<ConfirmBox>( | ||||
| 			confirmation, | ||||
| 			lang(lng_box_delete), | ||||
| 			st::attentionBoxButton, | ||||
| 			std::move(confirmCallback)); | ||||
| 		Ui::show(std::move(box)); | ||||
| 	}; | ||||
| 	AddActionButton( | ||||
| 		_wrap, | ||||
| 		Lang::Viewer(lng_profile_clear_history), | ||||
| 		rpl::single(true), | ||||
| 		std::move(callback)); | ||||
| 		 Window::ClearHistoryHandler(user)); | ||||
| } | ||||
| 
 | ||||
| void ActionsFiller::addDeleteConversationAction( | ||||
| 		not_null<UserData*> user) { | ||||
| 	auto callback = [user] { | ||||
| 		auto confirmation = lng_sure_delete_history( | ||||
| 			lt_contact, | ||||
| 			App::peerName(user)); | ||||
| 		auto confirmButton = lang(lng_box_delete); | ||||
| 		auto confirmCallback = [user] { | ||||
| 			Ui::hideLayer(); | ||||
| 			Ui::showChatsList(); | ||||
| 			App::main()->deleteConversation(user); | ||||
| 		}; | ||||
| 		auto box = Box<ConfirmBox>( | ||||
| 			confirmation, | ||||
| 			confirmButton, | ||||
| 			st::attentionBoxButton, | ||||
| 			std::move(confirmCallback)); | ||||
| 		Ui::show(std::move(box)); | ||||
| 	}; | ||||
| 	AddActionButton( | ||||
| 		_wrap, | ||||
| 		Lang::Viewer(lng_profile_delete_conversation), | ||||
| 		rpl::single(true), | ||||
| 		std::move(callback)); | ||||
| 		Window::DeleteAndLeaveHandler(user)); | ||||
| } | ||||
| 
 | ||||
| void ActionsFiller::addBotCommandActions(not_null<UserData*> user) { | ||||
|  |  | |||
|  | @ -88,51 +88,6 @@ History *FindWastedPin() { | |||
| 	return nullptr; | ||||
| } | ||||
| 
 | ||||
| auto ClearHistoryHandler(not_null<PeerData*> peer) { | ||||
| 	return [peer] { | ||||
| 		auto text = peer->isUser() | ||||
| 			? lng_sure_delete_history(lt_contact, peer->name) | ||||
| 			: lng_sure_delete_group_history(lt_group, peer->name); | ||||
| 		Ui::show(Box<ConfirmBox>(text, lang(lng_box_delete), st::attentionBoxButton, [peer] { | ||||
| 			if (!App::main()) return; | ||||
| 
 | ||||
| 			Ui::hideLayer(); | ||||
| 			Auth().api().clearHistory(peer); | ||||
| 		})); | ||||
| 	}; | ||||
| } | ||||
| 
 | ||||
| auto DeleteAndLeaveHandler(not_null<PeerData*> peer) { | ||||
| 	return [peer] { | ||||
| 		auto warningText = peer->isUser() ? lng_sure_delete_history(lt_contact, peer->name) : | ||||
| 			peer->isChat() ? lng_sure_delete_and_exit(lt_group, peer->name) : | ||||
| 			lang(peer->isMegagroup() ? lng_sure_leave_group : lng_sure_leave_channel); | ||||
| 		auto confirmText = lang(peer->isUser() ? lng_box_delete : lng_box_leave); | ||||
| 		auto &confirmStyle = peer->isChannel() ? st::defaultBoxButton : st::attentionBoxButton; | ||||
| 		Ui::show(Box<ConfirmBox>(warningText, confirmText, confirmStyle, [peer] { | ||||
| 			if (!App::main()) return; | ||||
| 
 | ||||
| 			Ui::hideLayer(); | ||||
| 			if (App::wnd()->controller()->activePeer.current() == peer) { | ||||
| 				Ui::showChatsList(); | ||||
| 			} | ||||
| 			if (peer->isUser()) { | ||||
| 				App::main()->deleteConversation(peer); | ||||
| 			} else if (auto chat = peer->asChat()) { | ||||
| 				App::main()->deleteAndExit(chat); | ||||
| 			} else if (auto channel = peer->asChannel()) { | ||||
| 				// Don't delete old history by default,
 | ||||
| 				// because Android app doesn't.
 | ||||
| 				//
 | ||||
| 				//if (auto migrateFrom = channel->migrateFrom()) {
 | ||||
| 				//	App::main()->deleteConversation(migrateFrom);
 | ||||
| 				//}
 | ||||
| 				Auth().api().leaveChannel(channel); | ||||
| 			} | ||||
| 		})); | ||||
| 	}; | ||||
| } | ||||
| 
 | ||||
| Filler::Filler( | ||||
| 	not_null<Controller*> controller, | ||||
| 	not_null<PeerData*> peer, | ||||
|  | @ -566,6 +521,76 @@ void PeerMenuAddChannelMembers(not_null<ChannelData*> channel) { | |||
| 	Auth().api().requestChannelMembersForAdd(channel, callback); | ||||
| } | ||||
| 
 | ||||
| base::lambda<void()> ClearHistoryHandler(not_null<PeerData*> peer) { | ||||
| 	return [peer] { | ||||
| 		const auto weak = std::make_shared<QPointer<ConfirmBox>>(); | ||||
| 		const auto text = peer->isSelf() | ||||
| 			? lang(lng_sure_delete_saved_messages) | ||||
| 			: peer->isUser() | ||||
| 			? lng_sure_delete_history(lt_contact, peer->name) | ||||
| 			: lng_sure_delete_group_history(lt_group, peer->name); | ||||
| 		auto callback = [=] { | ||||
| 			if (auto strong = *weak) { | ||||
| 				strong->closeBox(); | ||||
| 			} | ||||
| 			Auth().api().clearHistory(peer); | ||||
| 		}; | ||||
| 		*weak = Ui::show( | ||||
| 			Box<ConfirmBox>( | ||||
| 				text, | ||||
| 				lang(lng_box_delete), | ||||
| 				st::attentionBoxButton, | ||||
| 				std::move(callback)), | ||||
| 			LayerOption::KeepOther); | ||||
| 	}; | ||||
| } | ||||
| 
 | ||||
| base::lambda<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer) { | ||||
| 	return [peer] { | ||||
| 		const auto warningText = peer->isSelf() | ||||
| 			? lang(lng_sure_delete_saved_messages) | ||||
| 			: peer->isUser() | ||||
| 			? lng_sure_delete_history(lt_contact, peer->name) | ||||
| 			: peer->isChat() | ||||
| 			? lng_sure_delete_and_exit(lt_group, peer->name) | ||||
| 			: lang(peer->isMegagroup() | ||||
| 				? lng_sure_leave_group | ||||
| 				: lng_sure_leave_channel); | ||||
| 		const auto confirmText = lang(peer->isUser() | ||||
| 			? lng_box_delete | ||||
| 			: lng_box_leave); | ||||
| 		const auto &confirmStyle = peer->isChannel() | ||||
| 			? st::defaultBoxButton | ||||
| 			: st::attentionBoxButton; | ||||
| 		auto callback = [peer] { | ||||
| 			Ui::hideLayer(); | ||||
| 			if (App::wnd()->controller()->activePeer.current() == peer) { | ||||
| 				Ui::showChatsList(); | ||||
| 			} | ||||
| 			if (peer->isUser()) { | ||||
| 				App::main()->deleteConversation(peer); | ||||
| 			} else if (auto chat = peer->asChat()) { | ||||
| 				App::main()->deleteAndExit(chat); | ||||
| 			} else if (auto channel = peer->asChannel()) { | ||||
| 				// Don't delete old history by default,
 | ||||
| 				// because Android app doesn't.
 | ||||
| 				//
 | ||||
| 				//if (auto migrateFrom = channel->migrateFrom()) {
 | ||||
| 				//	App::main()->deleteConversation(migrateFrom);
 | ||||
| 				//}
 | ||||
| 				Auth().api().leaveChannel(channel); | ||||
| 			} | ||||
| 		}; | ||||
| 		Ui::show( | ||||
| 			Box<ConfirmBox>( | ||||
| 				warningText, | ||||
| 				confirmText, | ||||
| 				confirmStyle, | ||||
| 				std::move(callback)), | ||||
| 			LayerOption::KeepOther); | ||||
| 	}; | ||||
| } | ||||
| 
 | ||||
| void FillPeerMenu( | ||||
| 		not_null<Controller*> controller, | ||||
| 		not_null<PeerData*> peer, | ||||
|  |  | |||
|  | @ -45,6 +45,9 @@ void PeerMenuShareContactBox(not_null<UserData*> user); | |||
| void PeerMenuAddContact(not_null<UserData*> user); | ||||
| void PeerMenuAddChannelMembers(not_null<ChannelData*> channel); | ||||
| 
 | ||||
| base::lambda<void()> ClearHistoryHandler(not_null<PeerData*> peer); | ||||
| base::lambda<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer); | ||||
| 
 | ||||
| void ShowForwardMessagesBox( | ||||
| 	MessageIdsList &&items, | ||||
| 	base::lambda_once<void()> &&successCallback = nullptr); | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 John Preston
						John Preston