 556aa28df6
			
		
	
	
		556aa28df6
		
	
	
	
	
		
			
			The following are commits related to removed variables. apiwrap.cppe050e27: kSaveDraftBeforeQuitTimeout app.cpp113f665: serviceImageCacheSize boxes/auto_download_box.cppa0c6104: checked(Source source, Type type) boxes/background_preview_box.cppb6edf45: resultBytesPerPixelfe21b5a: ms boxes/calendar_box.cppae97704: yearIndex, monthIndex99bb093: ms boxes/connection_box.cppf794d8d: ping boxes/dictionaries_manager.cpp8353867: session boxes/peer_list_box.cpp2ce2a14: grayedWidth boxes/peers/add_participants_box.cpp07e010d: chat, channel boxes/self_destruction_box.cppfe9f02e: count chat_helpers/emoji_suggestions_widget.cppa12bc60: is(QLatin1String string) chat_helpers/field_autocomplete.cpp8c7a35c: atwidth, hashwidth chat_helpers/gifs_list_widget.cppff65734: inlineItems3d846fc: newSelectedd1687ab: kSaveDraftBeforeQuitTimeout chat_helpers/stickers_dice_pack.cppc83e297: kZeroDiceDocumentId chat_helpers/stickers_emoji_pack.cppd298953: length chat_helpers/stickers_list_widget.cppeb75859: index, x core/crash_reports.cpp5940ae6: LaunchedDateTimeStr, LaunchedBinaryName data/data_changes.cpp 3c4e959:clearRealtime data/data_cloud_file.cpp4b354b0: fromCloud, cacheTag data/data_document_media.cpp7db5359: kMaxVideoFrameArea data/data_messages.cpp794e315: wasCount data/data_photo_media.cppe27d2bc: index data/data_wall_paper.cppb6edf45: resultBytesPerPixel data/data_types.cppaa8f62d: kWebDocumentCacheTag, kStorageCacheMask history/admin_log/history_admin_log_inner.cpp794e315: canDelete, canForward history/history_location_manager.cpp60f45ab: kCoordPrecision9f90d3a: kMaxHttpRedirects history/history_message.cppcedf8a6: kPinnedMessageTextLimit history/history_widget.cppb305924: serviceColorefa5fc4: hasForward5e7aa4f: kTabbedSelectorToggleTooltipTimeoutMs, kTabbedSelectorToggleTooltipCount history/view/history_view_context_menu.cppfe1a90b: isVideoLink, isVoiceLink, isAudioLink settings.cppe2f54eb: defaultRecent settings/settings_folders.cppe8bf5bb: kRefreshSuggestedTimeout ui/filter_icon_panel.cppc4a0bc1: kDelayedHideTimeoutMs window/themes/window_theme_preview.cppef927c8: mutedCounter ----- Modified variables boxes/stickers_box.cpp554eb3a: _rows[pressedIndex] -> set data/data_notify_settings.cpp734c410: muteForSeconds -> muteUntil history/view/history_view_list_widget.cpp07528be: _items[index] -> viewe5f3bed: fromState, tillState history/history.cppcd3c1c6: kStatusShowClientsideRecordVideo -> kStatusShowClientsideRecordVoice storage/download_manager_mtproto.cppae8fb14: _queues[dcId] -> queue storage/localstorage.cpp357caf8: MTP::Environment::Production -> production
		
			
				
	
	
		
			247 lines
		
	
	
	
		
			6.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			247 lines
		
	
	
	
		
			6.4 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
| This file is part of Telegram Desktop,
 | |
| the official desktop application for the Telegram messaging service.
 | |
| 
 | |
| For license and copyright information please follow this link:
 | |
| https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | |
| */
 | |
| #include "data/data_changes.h"
 | |
| 
 | |
| #include "main/main_session.h"
 | |
| 
 | |
| namespace Data {
 | |
| 
 | |
| template <typename DataType, typename UpdateType>
 | |
| void Changes::Manager<DataType, UpdateType>::updated(
 | |
| 		not_null<DataType*> data,
 | |
| 		Flags flags,
 | |
| 		bool dropScheduled) {
 | |
| 	sendRealtimeNotifications(data, flags);
 | |
| 	if (dropScheduled) {
 | |
| 		const auto i = _updates.find(data);
 | |
| 		if (i != _updates.end()) {
 | |
| 			flags |= i->second;
 | |
| 			_updates.erase(i);
 | |
| 		}
 | |
| 		_stream.fire({ data, flags });
 | |
| 	} else {
 | |
| 		_updates[data] |= flags;
 | |
| 	}
 | |
| }
 | |
| 
 | |
| template <typename DataType, typename UpdateType>
 | |
| void Changes::Manager<DataType, UpdateType>::sendRealtimeNotifications(
 | |
| 		not_null<DataType*> data,
 | |
| 		Flags flags) {
 | |
| 	for (auto i = 0; i != kCount; ++i) {
 | |
| 		const auto flag = static_cast<Flag>(1U << i);
 | |
| 		if (flags & flag) {
 | |
| 			_realtimeStreams[i].fire({ data, flags });
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| template <typename DataType, typename UpdateType>
 | |
| rpl::producer<UpdateType> Changes::Manager<DataType, UpdateType>::updates(
 | |
| 		Flags flags) const {
 | |
| 	return _stream.events(
 | |
| 	) | rpl::filter([=](const UpdateType &update) {
 | |
| 		return (update.flags & flags);
 | |
| 	});
 | |
| }
 | |
| 
 | |
| template <typename DataType, typename UpdateType>
 | |
| rpl::producer<UpdateType> Changes::Manager<DataType, UpdateType>::updates(
 | |
| 		not_null<DataType*> data,
 | |
| 		Flags flags) const {
 | |
| 	return _stream.events(
 | |
| 	) | rpl::filter([=](const UpdateType &update) {
 | |
| 		const auto [updateData, updateFlags] = update;
 | |
| 		return (updateData == data) && (updateFlags & flags);
 | |
| 	});
 | |
| }
 | |
| 
 | |
| template <typename DataType, typename UpdateType>
 | |
| auto Changes::Manager<DataType, UpdateType>::realtimeUpdates(Flag flag) const
 | |
| -> rpl::producer<UpdateType> {
 | |
| 	return _realtimeStreams[details::CountBit(flag)].events();
 | |
| }
 | |
| 
 | |
| template <typename DataType, typename UpdateType>
 | |
| rpl::producer<UpdateType> Changes::Manager<DataType, UpdateType>::flagsValue(
 | |
| 		not_null<DataType*> data,
 | |
| 		Flags flags) const {
 | |
| 	return rpl::single(
 | |
| 		UpdateType{ data, flags }
 | |
| 	) | rpl::then(updates(data, flags));
 | |
| }
 | |
| 
 | |
| template <typename DataType, typename UpdateType>
 | |
| void Changes::Manager<DataType, UpdateType>::sendNotifications() {
 | |
| 	for (const auto [data, flags] : base::take(_updates)) {
 | |
| 		_stream.fire({ data, flags });
 | |
| 	}
 | |
| }
 | |
| 
 | |
| Changes::Changes(not_null<Main::Session*> session) : _session(session) {
 | |
| }
 | |
| 
 | |
| Main::Session &Changes::session() const {
 | |
| 	return *_session;
 | |
| }
 | |
| 
 | |
| void Changes::nameUpdated(
 | |
| 		not_null<PeerData*> peer,
 | |
| 		base::flat_set<QChar> oldFirstLetters) {
 | |
| 	_nameStream.fire({ peer, std::move(oldFirstLetters) });
 | |
| }
 | |
| 
 | |
| rpl::producer<NameUpdate> Changes::realtimeNameUpdates() const {
 | |
| 	return _nameStream.events();
 | |
| }
 | |
| 
 | |
| rpl::producer<NameUpdate> Changes::realtimeNameUpdates(
 | |
| 		not_null<PeerData*> peer) const {
 | |
| 	return _nameStream.events() | rpl::filter([=](const NameUpdate &update) {
 | |
| 		return (update.peer == peer);
 | |
| 	});
 | |
| }
 | |
| 
 | |
| void Changes::peerUpdated(not_null<PeerData*> peer, PeerUpdate::Flags flags) {
 | |
| 	_peerChanges.updated(peer, flags);
 | |
| 	scheduleNotifications();
 | |
| }
 | |
| 
 | |
| rpl::producer<PeerUpdate> Changes::peerUpdates(
 | |
| 		PeerUpdate::Flags flags) const {
 | |
| 	return _peerChanges.updates(flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<PeerUpdate> Changes::peerUpdates(
 | |
| 		not_null<PeerData*> peer,
 | |
| 		PeerUpdate::Flags flags) const {
 | |
| 	return _peerChanges.updates(peer, flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<PeerUpdate> Changes::peerFlagsValue(
 | |
| 		not_null<PeerData*> peer,
 | |
| 		PeerUpdate::Flags flags) const {
 | |
| 	return _peerChanges.flagsValue(peer, flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<PeerUpdate> Changes::realtimePeerUpdates(
 | |
| 		PeerUpdate::Flag flag) const {
 | |
| 	return _peerChanges.realtimeUpdates(flag);
 | |
| }
 | |
| 
 | |
| void Changes::historyUpdated(
 | |
| 		not_null<History*> history,
 | |
| 		HistoryUpdate::Flags flags) {
 | |
| 	_historyChanges.updated(history, flags);
 | |
| 	scheduleNotifications();
 | |
| }
 | |
| 
 | |
| rpl::producer<HistoryUpdate> Changes::historyUpdates(
 | |
| 		HistoryUpdate::Flags flags) const {
 | |
| 	return _historyChanges.updates(flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<HistoryUpdate> Changes::historyUpdates(
 | |
| 		not_null<History*> history,
 | |
| 		HistoryUpdate::Flags flags) const {
 | |
| 	return _historyChanges.updates(history, flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<HistoryUpdate> Changes::historyFlagsValue(
 | |
| 		not_null<History*> history,
 | |
| 		HistoryUpdate::Flags flags) const {
 | |
| 	return _historyChanges.flagsValue(history, flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<HistoryUpdate> Changes::realtimeHistoryUpdates(
 | |
| 		HistoryUpdate::Flag flag) const {
 | |
| 	return _historyChanges.realtimeUpdates(flag);
 | |
| }
 | |
| 
 | |
| void Changes::messageUpdated(
 | |
| 		not_null<HistoryItem*> item,
 | |
| 		MessageUpdate::Flags flags) {
 | |
| 	const auto drop = (flags & MessageUpdate::Flag::Destroyed);
 | |
| 	_messageChanges.updated(item, flags, drop);
 | |
| 	if (!drop) {
 | |
| 		scheduleNotifications();
 | |
| 	}
 | |
| }
 | |
| 
 | |
| rpl::producer<MessageUpdate> Changes::messageUpdates(
 | |
| 		MessageUpdate::Flags flags) const {
 | |
| 	return _messageChanges.updates(flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<MessageUpdate> Changes::messageUpdates(
 | |
| 		not_null<HistoryItem*> item,
 | |
| 		MessageUpdate::Flags flags) const {
 | |
| 	return _messageChanges.updates(item, flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<MessageUpdate> Changes::messageFlagsValue(
 | |
| 		not_null<HistoryItem*> item,
 | |
| 		MessageUpdate::Flags flags) const {
 | |
| 	return _messageChanges.flagsValue(item, flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<MessageUpdate> Changes::realtimeMessageUpdates(
 | |
| 		MessageUpdate::Flag flag) const {
 | |
| 	return _messageChanges.realtimeUpdates(flag);
 | |
| }
 | |
| 
 | |
| void Changes::entryUpdated(
 | |
| 		not_null<Dialogs::Entry*> entry,
 | |
| 		EntryUpdate::Flags flags) {
 | |
| 	_entryChanges.updated(entry, flags);
 | |
| 	scheduleNotifications();
 | |
| }
 | |
| 
 | |
| rpl::producer<EntryUpdate> Changes::entryUpdates(
 | |
| 		EntryUpdate::Flags flags) const {
 | |
| 	return _entryChanges.updates(flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<EntryUpdate> Changes::entryUpdates(
 | |
| 		not_null<Dialogs::Entry*> entry,
 | |
| 		EntryUpdate::Flags flags) const {
 | |
| 	return _entryChanges.updates(entry, flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<EntryUpdate> Changes::entryFlagsValue(
 | |
| 		not_null<Dialogs::Entry*> entry,
 | |
| 		EntryUpdate::Flags flags) const {
 | |
| 	return _entryChanges.flagsValue(entry, flags);
 | |
| }
 | |
| 
 | |
| rpl::producer<EntryUpdate> Changes::realtimeEntryUpdates(
 | |
| 		EntryUpdate::Flag flag) const {
 | |
| 	return _entryChanges.realtimeUpdates(flag);
 | |
| }
 | |
| 
 | |
| void Changes::scheduleNotifications() {
 | |
| 	if (!_notify) {
 | |
| 		_notify = true;
 | |
| 		crl::on_main(&session(), [=] {
 | |
| 			sendNotifications();
 | |
| 		});
 | |
| 	}
 | |
| }
 | |
| 
 | |
| void Changes::sendNotifications() {
 | |
| 	if (!_notify) {
 | |
| 		return;
 | |
| 	}
 | |
| 	_notify = false;
 | |
| 	_peerChanges.sendNotifications();
 | |
| 	_historyChanges.sendNotifications();
 | |
| 	_messageChanges.sendNotifications();
 | |
| 	_entryChanges.sendNotifications();
 | |
| }
 | |
| 
 | |
| } // namespace Data
 |