Browse Source

Replies footer:

Fix handling first comment
Handle comments after message is sent
master
Eduard Kuzmenko 4 years ago
parent
commit
d24dc657a4
  1. 7
      src/components/chat/bubbles.ts
  2. 4
      src/components/chat/replies.ts
  3. 70
      src/layer.d.ts
  4. 2
      src/lib/richtextprocessor.ts
  5. 108
      src/scripts/in/schema_additional_params.json

7
src/components/chat/bubbles.ts

@ -43,6 +43,7 @@ import { FocusDirection } from "../../helpers/fastSmoothScroll";
import useHeavyAnimationCheck, { getHeavyAnimationPromise, dispatchHeavyAnimationEvent } from "../../hooks/useHeavyAnimationCheck"; import useHeavyAnimationCheck, { getHeavyAnimationPromise, dispatchHeavyAnimationEvent } from "../../hooks/useHeavyAnimationCheck";
import { fastRaf } from "../../helpers/schedulers"; import { fastRaf } from "../../helpers/schedulers";
import { deferredPromise } from "../../helpers/cancellablePromise"; import { deferredPromise } from "../../helpers/cancellablePromise";
import RepliesElement from "./replies";
const USE_MEDIA_TAILS = false; const USE_MEDIA_TAILS = false;
const IGNORE_ACTIONS = ['messageActionHistoryClear']; const IGNORE_ACTIONS = ['messageActionHistoryClear'];
@ -191,6 +192,12 @@ export default class ChatBubbles {
/////this.log('message_sent', bubble); /////this.log('message_sent', bubble);
if(message.replies) {
const repliesElement = bubble.querySelector('replies-element') as RepliesElement;
repliesElement.message = message;
repliesElement.init();
}
if(message.media?.document && !message.media.document.type) { if(message.media?.document && !message.media.document.type) {
const div = bubble.querySelector(`.document-container[data-mid="${tempId}"] .document`); const div = bubble.querySelector(`.document-container[data-mid="${tempId}"] .document`);
if(div) { if(div) {

4
src/components/chat/replies.ts

@ -48,7 +48,7 @@ export default class RepliesElement extends HTMLElement {
if(replies?.recent_repliers) { if(replies?.recent_repliers) {
if(leftPart && !leftPart.classList.contains('replies-footer-avatars')) { if(leftPart && !leftPart.classList.contains('replies-footer-avatars')) {
leftPart.remove(); this.innerHTML = '';
leftPart = null; leftPart = null;
} }
@ -130,7 +130,7 @@ export default class RepliesElement extends HTMLElement {
this.innerHTML = `<span class="tgico-commentssticker"></span><span class="replies-beside-text">${replies?.replies ? formatNumber(replies.replies, 0) : ''}</span>`; this.innerHTML = `<span class="tgico-commentssticker"></span><span class="replies-beside-text">${replies?.replies ? formatNumber(replies.replies, 0) : ''}</span>`;
} }
if(replies && !this.updated) { if(replies && !this.updated && !this.message.pFlags.is_outgoing) {
appMessagesManager.subscribeRepliesThread(this.message.peerId, this.message.mid); appMessagesManager.subscribeRepliesThread(this.message.peerId, this.message.mid);
appMessagesManager.updateMessage(this.message.peerId, this.message.mid, 'replies_updated'); appMessagesManager.updateMessage(this.message.peerId, this.message.mid, 'replies_updated');
this.updated = true; this.updated = true;

70
src/layer.d.ts vendored

@ -808,6 +808,7 @@ export namespace Message {
edit_hide?: true, edit_hide?: true,
pinned?: true, pinned?: true,
unread?: true, unread?: true,
is_outgoing?: true,
}>, }>,
id: number, id: number,
from_id?: Peer, from_id?: Peer,
@ -831,7 +832,6 @@ export namespace Message {
deleted?: boolean, deleted?: boolean,
peerId?: number, peerId?: number,
fromId?: number, fromId?: number,
canBeEdited?: boolean,
rReply?: string rReply?: string
}; };
@ -846,6 +846,7 @@ export namespace Message {
post?: true, post?: true,
legacy?: true, legacy?: true,
unread?: true, unread?: true,
is_outgoing?: true,
}>, }>,
id: number, id: number,
from_id?: Peer, from_id?: Peer,
@ -857,7 +858,6 @@ export namespace Message {
deleted?: boolean, deleted?: boolean,
peerId?: number, peerId?: number,
fromId?: number, fromId?: number,
canBeEdited?: boolean,
rReply?: string rReply?: string
}; };
} }
@ -3847,160 +3847,138 @@ export namespace MessageEntity {
export type messageEntityUnknown = { export type messageEntityUnknown = {
_: 'messageEntityUnknown', _: 'messageEntityUnknown',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityMention = { export type messageEntityMention = {
_: 'messageEntityMention', _: 'messageEntityMention',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityHashtag = { export type messageEntityHashtag = {
_: 'messageEntityHashtag', _: 'messageEntityHashtag',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityBotCommand = { export type messageEntityBotCommand = {
_: 'messageEntityBotCommand', _: 'messageEntityBotCommand',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityUrl = { export type messageEntityUrl = {
_: 'messageEntityUrl', _: 'messageEntityUrl',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityEmail = { export type messageEntityEmail = {
_: 'messageEntityEmail', _: 'messageEntityEmail',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityBold = { export type messageEntityBold = {
_: 'messageEntityBold', _: 'messageEntityBold',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityItalic = { export type messageEntityItalic = {
_: 'messageEntityItalic', _: 'messageEntityItalic',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityCode = { export type messageEntityCode = {
_: 'messageEntityCode', _: 'messageEntityCode',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityPre = { export type messageEntityPre = {
_: 'messageEntityPre', _: 'messageEntityPre',
offset: number, offset: number,
length: number, length: number,
language: string, language: string
nested?: Array<MessageEntity>
}; };
export type messageEntityTextUrl = { export type messageEntityTextUrl = {
_: 'messageEntityTextUrl', _: 'messageEntityTextUrl',
offset: number, offset: number,
length: number, length: number,
url: string, url: string
nested?: Array<MessageEntity>
}; };
export type messageEntityMentionName = { export type messageEntityMentionName = {
_: 'messageEntityMentionName', _: 'messageEntityMentionName',
offset: number, offset: number,
length: number, length: number,
user_id: number, user_id: number
nested?: Array<MessageEntity>
}; };
export type inputMessageEntityMentionName = { export type inputMessageEntityMentionName = {
_: 'inputMessageEntityMentionName', _: 'inputMessageEntityMentionName',
offset: number, offset: number,
length: number, length: number,
user_id: InputUser, user_id: InputUser
nested?: Array<MessageEntity>
}; };
export type messageEntityPhone = { export type messageEntityPhone = {
_: 'messageEntityPhone', _: 'messageEntityPhone',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityCashtag = { export type messageEntityCashtag = {
_: 'messageEntityCashtag', _: 'messageEntityCashtag',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityUnderline = { export type messageEntityUnderline = {
_: 'messageEntityUnderline', _: 'messageEntityUnderline',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityStrike = { export type messageEntityStrike = {
_: 'messageEntityStrike', _: 'messageEntityStrike',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityBlockquote = { export type messageEntityBlockquote = {
_: 'messageEntityBlockquote', _: 'messageEntityBlockquote',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityBankCard = { export type messageEntityBankCard = {
_: 'messageEntityBankCard', _: 'messageEntityBankCard',
offset: number, offset: number,
length: number, length: number
nested?: Array<MessageEntity>
}; };
export type messageEntityEmoji = { export type messageEntityEmoji = {
_: 'messageEntityEmoji', _: 'messageEntityEmoji',
offset?: number, offset?: number,
length?: number, length?: number,
unicode?: string, unicode?: string
nested?: Array<MessageEntity>
}; };
export type messageEntityHighlight = { export type messageEntityHighlight = {
_: 'messageEntityHighlight', _: 'messageEntityHighlight',
offset?: number, offset?: number,
length?: number, length?: number
nested?: Array<MessageEntity>
}; };
export type messageEntityLinebreak = { export type messageEntityLinebreak = {
_: 'messageEntityLinebreak', _: 'messageEntityLinebreak',
offset?: number, offset?: number,
length?: number, length?: number
nested?: Array<MessageEntity>
}; };
} }

2
src/lib/richtextprocessor.ts

@ -349,7 +349,6 @@ namespace RichTextProcessor {
[_ in MessageEntity['_']]: true [_ in MessageEntity['_']]: true
}>, }>,
nested?: true,
contextHashtag?: string contextHashtag?: string
}> = {}) { }> = {}) {
if(!text || !text.length) { if(!text || !text.length) {
@ -499,7 +498,6 @@ namespace RichTextProcessor {
if(entity._ === 'messageEntityTextUrl') { if(entity._ === 'messageEntityTextUrl') {
url = (entity as MessageEntity.messageEntityTextUrl).url; url = (entity as MessageEntity.messageEntityTextUrl).url;
url = wrapUrl(url, true); url = wrapUrl(url, true);
//inner = wrapRichNestedText(entityText, entity.nested, options);
} else { } else {
url = wrapUrl(entityText, false); url = wrapUrl(entityText, false);
//inner = encodeEntities(replaceUrlEncodings(entityText)); //inner = encodeEntities(replaceUrlEncodings(entityText));

108
src/scripts/in/schema_additional_params.json

@ -69,8 +69,8 @@
{"name": "peerId", "type": "number"}, {"name": "peerId", "type": "number"},
{"name": "fromId", "type": "number"}, {"name": "fromId", "type": "number"},
{"name": "grouped_id", "type": "string"}, {"name": "grouped_id", "type": "string"},
{"name": "canBeEdited", "type": "boolean"},
{"name": "unread", "type": "true"}, {"name": "unread", "type": "true"},
{"name": "is_outgoing", "type": "true"},
{"name": "rReply", "type": "string"} {"name": "rReply", "type": "string"}
] ]
}, { }, {
@ -80,8 +80,8 @@
{"name": "deleted", "type": "boolean"}, {"name": "deleted", "type": "boolean"},
{"name": "peerId", "type": "number"}, {"name": "peerId", "type": "number"},
{"name": "fromId", "type": "number"}, {"name": "fromId", "type": "number"},
{"name": "canBeEdited", "type": "boolean"},
{"name": "unread", "type": "true"}, {"name": "unread", "type": "true"},
{"name": "is_outgoing", "type": "true"},
{"name": "rReply", "type": "string"} {"name": "rReply", "type": "string"}
] ]
}, { }, {
@ -99,121 +99,23 @@
"params": [ "params": [
{"name": "offset", "type": "number"}, {"name": "offset", "type": "number"},
{"name": "length", "type": "number"}, {"name": "length", "type": "number"},
{"name": "unicode", "type": "string"}, {"name": "unicode", "type": "string"}
{"name": "nested", "type": "Array<MessageEntity>"}
], ],
"type": "MessageEntity" "type": "MessageEntity"
}, { }, {
"predicate": "messageEntityHighlight", "predicate": "messageEntityHighlight",
"params": [ "params": [
{"name": "offset", "type": "number"}, {"name": "offset", "type": "number"},
{"name": "length", "type": "number"}, {"name": "length", "type": "number"}
{"name": "nested", "type": "Array<MessageEntity>"}
], ],
"type": "MessageEntity" "type": "MessageEntity"
}, { }, {
"predicate": "messageEntityLinebreak", "predicate": "messageEntityLinebreak",
"params": [ "params": [
{"name": "offset", "type": "number"}, {"name": "offset", "type": "number"},
{"name": "length", "type": "number"}, {"name": "length", "type": "number"}
{"name": "nested", "type": "Array<MessageEntity>"}
], ],
"type": "MessageEntity" "type": "MessageEntity"
}, {
"predicate": "messageEntityUnknown",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityMention",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityHashtag",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityBotCommand",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityUrl",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityEmail",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityBold",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityItalic",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityCode",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityPre",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityTextUrl",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityMentionName",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityPhone",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityCashtag",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityUnderline",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityStrike",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityBlockquote",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "messageEntityBankCard",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, {
"predicate": "inputMessageEntityMentionName",
"params": [
{"name": "nested", "type": "Array<MessageEntity>"}
]
}, { }, {
"predicate": "user", "predicate": "user",
"params": [ "params": [

Loading…
Cancel
Save