Esempio n. 1
0
void Element::refreshMedia() {
	_flags &= ~Flag::HiddenByGroup;

	const auto item = data();
	const auto media = item->media();
	if (media && media->canBeGrouped()) {
		if (const auto group = history()->owner().groups().find(item)) {
			if (group->items.back() != item) {
				_media = nullptr;
				_flags |= Flag::HiddenByGroup;
			} else {
				_media = std::make_unique<HistoryGroupedMedia>(
					this,
					group->items);
				if (!pendingResize()) {
					history()->owner().requestViewResize(this);
				}
			}
			return;
		}
	}
	if (_data->media()) {
		_media = _data->media()->createView(this);
	} else {
		_media = nullptr;
	}
}
Esempio n. 2
0
bool Groups::isGrouped(not_null<HistoryItem*> item) const {
	if (!item->groupId()) {
		return false;
	}
	const auto media = item->media();
	return media && media->canBeGrouped();
}
bool HistoryGroupedMedia::applyGroup(
		const std::vector<not_null<HistoryItem*>> &items) {
	Expects(items.size() <= kMaxDisplayedGroupSize);

	if (items.empty()) {
		return false;
	}
	if (validateGroupParts(items)) {
		return true;
	}

	for (const auto item : items) {
		const auto media = item->media();
		Assert(media != nullptr && media->canBeGrouped());

		_parts.push_back(Part(item));
		_parts.back().content = media->createView(_parent, item);
	};
	return true;
}