Support unknown dimensions in pageBlockEmbed.

GitOrigin-RevId: fb808fb13abfa0d2f6b4c460e5102984c149ef3d
This commit is contained in:
levlam 2019-02-06 03:17:20 +03:00
parent bc8b5d359c
commit c6bbc4265e
2 changed files with 9 additions and 5 deletions

View File

@ -765,7 +765,7 @@ pageBlockVideo video:video caption:pageBlockCaption need_autoplay:Bool is_looped
//@description A page cover @cover Cover
pageBlockCover cover:PageBlock = PageBlock;
//@description An embedded web page @url Web page URL, if available @html HTML-markup of the embedded page @poster_photo Poster photo, if available; may be null @width Block width @height Block height @caption Block caption @is_full_width True, if the block should be full width @allow_scrolling True, if scrolling should be allowed
//@description An embedded web page @url Web page URL, if available @html HTML-markup of the embedded page @poster_photo Poster photo, if available; may be null @width Block width, 0 if unknown @height Block height, 0 if unknown @caption Block caption @is_full_width True, if the block should be full width @allow_scrolling True, if scrolling should be allowed
pageBlockEmbedded url:string html:string poster_photo:photo width:int32 height:int32 caption:pageBlockCaption is_full_width:Bool allow_scrolling:Bool = PageBlock;
//@description An embedded post @url Web page URL @author Post author @author_photo Post author photo @date Point in time (Unix timestamp) when the post was created; 0 if unknown @page_blocks Post content @caption Post caption

View File

@ -2690,6 +2690,7 @@ unique_ptr<WebPagesManager::PageBlock> WebPagesManager::get_page_block(
auto page_block = move_tl_object_as<telegram_api::pageBlockEmbed>(page_block_ptr);
bool is_full_width = (page_block->flags_ & telegram_api::pageBlockEmbed::FULL_WIDTH_MASK) != 0;
bool allow_scrolling = (page_block->flags_ & telegram_api::pageBlockEmbed::ALLOW_SCROLLING_MASK) != 0;
bool has_dimensions = (page_block->flags_ & telegram_api::pageBlockEmbed::W_MASK) != 0;
auto it = (page_block->flags_ & telegram_api::pageBlockEmbed::POSTER_PHOTO_ID_MASK) != 0
? photos.find(page_block->poster_photo_id_)
: photos.end();
@ -2699,10 +2700,13 @@ unique_ptr<WebPagesManager::PageBlock> WebPagesManager::get_page_block(
} else {
poster_photo = it->second;
}
return td::make_unique<PageBlockEmbedded>(std::move(page_block->url_), std::move(page_block->html_),
std::move(poster_photo), get_dimensions(page_block->w_, page_block->h_),
get_page_block_caption(std::move(page_block->caption_), documents),
is_full_width, allow_scrolling);
Dimensions dimensions;
if (has_dimensions) {
dimensions = get_dimensions(page_block->w_, page_block->h_);
}
return td::make_unique<PageBlockEmbedded>(
std::move(page_block->url_), std::move(page_block->html_), std::move(poster_photo), dimensions,
get_page_block_caption(std::move(page_block->caption_), documents), is_full_width, allow_scrolling);
}
case telegram_api::pageBlockEmbedPost::ID: {
auto page_block = move_tl_object_as<telegram_api::pageBlockEmbedPost>(page_block_ptr);