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"; @@ -43,6 +43,7 @@ import { FocusDirection } from "../../helpers/fastSmoothScroll";
import useHeavyAnimationCheck, { getHeavyAnimationPromise, dispatchHeavyAnimationEvent } from "../../hooks/useHeavyAnimationCheck";
import { fastRaf } from "../../helpers/schedulers";
import { deferredPromise } from "../../helpers/cancellablePromise";
import RepliesElement from "./replies";
const USE_MEDIA_TAILS = false;
const IGNORE_ACTIONS = ['messageActionHistoryClear'];
@ -191,6 +192,12 @@ export default class ChatBubbles { @@ -191,6 +192,12 @@ export default class ChatBubbles {
/////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) {
const div = bubble.querySelector(`.document-container[data-mid="${tempId}"] .document`);
if(div) {

4
src/components/chat/replies.ts

@ -48,7 +48,7 @@ export default class RepliesElement extends HTMLElement { @@ -48,7 +48,7 @@ export default class RepliesElement extends HTMLElement {
if(replies?.recent_repliers) {
if(leftPart && !leftPart.classList.contains('replies-footer-avatars')) {
leftPart.remove();
this.innerHTML = '';
leftPart = null;
}
@ -130,7 +130,7 @@ export default class RepliesElement extends HTMLElement { @@ -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>`;
}
if(replies && !this.updated) {
if(replies && !this.updated && !this.message.pFlags.is_outgoing) {
appMessagesManager.subscribeRepliesThread(this.message.peerId, this.message.mid);
appMessagesManager.updateMessage(this.message.peerId, this.message.mid, 'replies_updated');
this.updated = true;

70
src/layer.d.ts vendored

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

2
src/lib/richtextprocessor.ts

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

108
src/scripts/in/schema_additional_params.json

@ -69,8 +69,8 @@ @@ -69,8 +69,8 @@
{"name": "peerId", "type": "number"},
{"name": "fromId", "type": "number"},
{"name": "grouped_id", "type": "string"},
{"name": "canBeEdited", "type": "boolean"},
{"name": "unread", "type": "true"},
{"name": "is_outgoing", "type": "true"},
{"name": "rReply", "type": "string"}
]
}, {
@ -80,8 +80,8 @@ @@ -80,8 +80,8 @@
{"name": "deleted", "type": "boolean"},
{"name": "peerId", "type": "number"},
{"name": "fromId", "type": "number"},
{"name": "canBeEdited", "type": "boolean"},
{"name": "unread", "type": "true"},
{"name": "is_outgoing", "type": "true"},
{"name": "rReply", "type": "string"}
]
}, {
@ -99,121 +99,23 @@ @@ -99,121 +99,23 @@
"params": [
{"name": "offset", "type": "number"},
{"name": "length", "type": "number"},
{"name": "unicode", "type": "string"},
{"name": "nested", "type": "Array<MessageEntity>"}
{"name": "unicode", "type": "string"}
],
"type": "MessageEntity"
}, {
"predicate": "messageEntityHighlight",
"params": [
{"name": "offset", "type": "number"},
{"name": "length", "type": "number"},
{"name": "nested", "type": "Array<MessageEntity>"}
{"name": "length", "type": "number"}
],
"type": "MessageEntity"
}, {
"predicate": "messageEntityLinebreak",
"params": [
{"name": "offset", "type": "number"},
{"name": "length", "type": "number"},
{"name": "nested", "type": "Array<MessageEntity>"}
{"name": "length", "type": "number"}
],
"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",
"params": [

Loading…
Cancel
Save