1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-24 22:46:41 +07:00

#4 fixed photo caption trimming

This commit is contained in:
Fedor Katurov 2021-05-06 10:51:52 +07:00
parent 34155f39ba
commit 01211eae0f

View file

@ -306,14 +306,9 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
* Calculates, how much should we cut off the text to match photo caption limitations
*/
private trimTextForPhoto = (text: string, user: UsersUserFull): string => {
// Full markup
const full = this.themeText(text, user);
// Rest info except text
const others = this.themeText("", user);
const withText = this.themeText(text, user);
const withoutText = this.themeText("", user);
// How much rest markup takes
const diff = full.length - others.length;
return full.slice(0, PHOTO_CAPTION_LIMIT - diff);
return withText.slice(0, PHOTO_CAPTION_LIMIT - withoutText.length);
};
}