Fix bubble eposition
Fix audio first click after peer change Fix reply in scheduled
This commit is contained in:
parent
3047285307
commit
1b67588fc0
@ -30,23 +30,24 @@ export function decodeWaveform(waveform: Uint8Array | number[]) {
|
||||
waveform = new Uint8Array(waveform);
|
||||
}
|
||||
|
||||
var bitCount = waveform.length * 8;
|
||||
var valueCount = bitCount / 5 | 0;
|
||||
const bitCount = waveform.length * 8;
|
||||
const valueCount = bitCount / 5 | 0;
|
||||
if(!valueCount) {
|
||||
return new Uint8Array([]);
|
||||
}
|
||||
|
||||
let result: Uint8Array;
|
||||
try {
|
||||
var dataView = new DataView(waveform.buffer);
|
||||
var result = new Uint8Array(valueCount);
|
||||
for(var i = 0; i < valueCount; i++) {
|
||||
var byteIndex = i * 5 / 8 | 0;
|
||||
var bitShift = i * 5 % 8;
|
||||
var value = dataView.getUint16(byteIndex, true);
|
||||
const dataView = new DataView(waveform.buffer);
|
||||
result = new Uint8Array(valueCount);
|
||||
for(let i = 0; i < valueCount; i++) {
|
||||
const byteIndex = i * 5 / 8 | 0;
|
||||
const bitShift = i * 5 % 8;
|
||||
const value = dataView.getUint16(byteIndex, true);
|
||||
result[i] = (value >> bitShift) & 0b00011111;
|
||||
}
|
||||
} catch(err) {
|
||||
return new Uint8Array([]);
|
||||
result = new Uint8Array([]);
|
||||
}
|
||||
|
||||
/* var byteIndex = (valueCount - 1) / 8 | 0;
|
||||
@ -448,6 +449,9 @@ export default class AudioElement extends HTMLElement {
|
||||
//onLoad();
|
||||
//} else {
|
||||
const r = (e: Event) => {
|
||||
if(this.audio.src) {
|
||||
return;
|
||||
}
|
||||
//onLoad();
|
||||
//cancelEvent(e);
|
||||
appMediaPlaybackController.resolveWaitingForLoadMedia(this.message.peerId, this.message.mid);
|
||||
@ -482,7 +486,9 @@ export default class AudioElement extends HTMLElement {
|
||||
});
|
||||
};
|
||||
|
||||
if(!this.audio.src) {
|
||||
attachClickEvent(this, r, {once: true, capture: true, passive: false});
|
||||
}
|
||||
//}
|
||||
}
|
||||
} else {
|
||||
|
@ -254,7 +254,9 @@ export default class ChatBubbles {
|
||||
this.renderMessage(mounted.message, true, false, mounted.bubble, updatePosition);
|
||||
|
||||
if(updatePosition) {
|
||||
(this.messagesQueuePromise || Promise.resolve()).then(() => {
|
||||
this.deleteEmptyDateGroups();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -271,9 +273,13 @@ export default class ChatBubbles {
|
||||
});
|
||||
|
||||
this.listenerSetter.add(rootScope, 'messages_downloaded', (e) => {
|
||||
const mids: number[] = e.detail;
|
||||
const {peerId, mids} = e.detail;
|
||||
|
||||
mids.forEach(mid => {
|
||||
if(peerId !== this.peerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
(mids as number[]).forEach(mid => {
|
||||
/* const promise = (this.scrollable.scrollLocked && this.scrollable.scrollLockedPromise) || Promise.resolve();
|
||||
promise.then(() => {
|
||||
|
||||
@ -288,7 +294,7 @@ export default class ChatBubbles {
|
||||
|
||||
const message = this.chat.getMessage(mid);
|
||||
|
||||
const repliedMessage = this.chat.getMessage(replyMid);
|
||||
const repliedMessage = this.chat.type === 'scheduled' ? this.appMessagesManager.getMessageByPeer(this.peerId, replyMid) : this.chat.getMessage(replyMid);
|
||||
if(repliedMessage.deleted) { // чтобы не пыталось бесконечно загрузить удалённое сообщение
|
||||
delete message.reply_to_mid; // WARNING!
|
||||
}
|
||||
@ -628,7 +634,8 @@ export default class ChatBubbles {
|
||||
if(isReplyClick && bubble.classList.contains('is-reply')/* || bubble.classList.contains('forwarded') */) {
|
||||
this.replyFollowHistory.push(+bubble.dataset.mid);
|
||||
let originalMessageId = +bubble.getAttribute('data-original-mid');
|
||||
this.chat.setPeer(this.peerId, originalMessageId);
|
||||
this.chat.appImManager.setInnerPeer(this.peerId, originalMessageId);
|
||||
//this.chat.setPeer(this.peerId, originalMessageId);
|
||||
}
|
||||
} else if(target.tagName == 'IMG' && target.parentElement.tagName == "AVATAR-ELEMENT") {
|
||||
let peerId = +target.parentElement.getAttribute('peer');
|
||||
@ -1369,12 +1376,12 @@ export default class ChatBubbles {
|
||||
|
||||
// * 1 for date, 1 for date sentinel
|
||||
let index = 2 + i;
|
||||
if(bubble.parentElement) { // * if already mounted
|
||||
/* if(bubble.parentElement) { // * if already mounted
|
||||
const currentIndex = whichChild(bubble);
|
||||
if(index > currentIndex) {
|
||||
index -= 1; // * minus for already mounted
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
positionElementByIndex(bubble, dateMessage.container, index);
|
||||
} else {
|
||||
@ -2111,7 +2118,7 @@ export default class ChatBubbles {
|
||||
}
|
||||
} else {
|
||||
if(message.reply_to_mid) {
|
||||
let originalMessage = this.chat.getMessage(message.reply_to_mid);
|
||||
let originalMessage = this.chat.type === 'scheduled' ? this.appMessagesManager.getMessageByPeer(this.peerId, message.reply_to_mid) : this.chat.getMessage(message.reply_to_mid);
|
||||
let originalPeerTitle = this.appPeersManager.getPeerTitle(originalMessage.fromId || originalMessage.fwdFromId, true) || '';
|
||||
|
||||
/////////this.log('message to render reply', originalMessage, originalPeerTitle, bubble, message);
|
||||
|
@ -415,11 +415,11 @@ export function calcImageInBox(imageW: number, imageH: number, boxW: number, box
|
||||
}
|
||||
|
||||
export function positionElementByIndex(element: HTMLElement, container: HTMLElement, pos: number) {
|
||||
const prevPos = whichChild(element);
|
||||
const prevPos = element.parentElement === container ? whichChild(element) : -1;
|
||||
|
||||
if(prevPos == pos) {
|
||||
if(prevPos === pos) {
|
||||
return false;
|
||||
} else if(prevPos != -1 && prevPos < pos) { // was higher
|
||||
} else if(prevPos !== -1 && prevPos < pos) { // was higher
|
||||
pos += 1;
|
||||
}
|
||||
|
||||
|
@ -4373,7 +4373,7 @@ export class AppMessagesManager {
|
||||
const msgIds: InputMessage[] = mids.map((msgId: number) => {
|
||||
return {
|
||||
_: 'inputMessageID',
|
||||
id: msgId
|
||||
id: this.getLocalMessageId(msgId)
|
||||
};
|
||||
});
|
||||
|
||||
@ -4396,7 +4396,7 @@ export class AppMessagesManager {
|
||||
this.saveMessages(getMessagesResult.messages);
|
||||
}
|
||||
|
||||
rootScope.broadcast('messages_downloaded', mids);
|
||||
rootScope.broadcast('messages_downloaded', {peerId: +peerId, mids});
|
||||
}));
|
||||
}
|
||||
|
||||
@ -4411,7 +4411,7 @@ export class AppMessagesManager {
|
||||
|
||||
public wrapSingleMessage(peerId: number, msgId: number, overwrite = false): Promise<void> {
|
||||
if(this.getMessagesStorage(peerId)[msgId] && !overwrite) {
|
||||
rootScope.broadcast('messages_downloaded', [msgId]);
|
||||
rootScope.broadcast('messages_downloaded', {peerId, mids: [msgId]});
|
||||
return Promise.resolve();
|
||||
} else if(!this.needSingleMessages[peerId] || this.needSingleMessages[peerId].indexOf(msgId) == -1) {
|
||||
(this.needSingleMessages[peerId] ?? (this.needSingleMessages[peerId] = [])).push(msgId);
|
||||
|
@ -179,7 +179,7 @@ export class AppPollsManager {
|
||||
|
||||
return apiManager.invokeApi('messages.sendVote', {
|
||||
peer: inputPeer,
|
||||
msg_id: messageId,
|
||||
msg_id: message.id,
|
||||
options
|
||||
}).then(updates => {
|
||||
this.log('sendVote updates:', updates);
|
||||
@ -192,7 +192,7 @@ export class AppPollsManager {
|
||||
|
||||
return apiManager.invokeApi('messages.getPollResults', {
|
||||
peer: inputPeer,
|
||||
msg_id: message.mid
|
||||
msg_id: message.id
|
||||
}).then(updates => {
|
||||
apiUpdatesManager.processUpdateMessage(updates);
|
||||
this.log('getResults updates:', updates);
|
||||
@ -202,7 +202,7 @@ export class AppPollsManager {
|
||||
public getVotes(message: any, option?: Uint8Array, offset?: string, limit = 20) {
|
||||
return apiManager.invokeApi('messages.getPollVotes', {
|
||||
peer: appPeersManager.getInputPeerById(message.peerId),
|
||||
id: message.mid,
|
||||
id: message.id,
|
||||
option,
|
||||
offset,
|
||||
limit
|
||||
|
@ -43,7 +43,7 @@ type BroadcastEvents = {
|
||||
'message_sent': {storage: MessagesStorage, tempId: number, tempMessage: any, mid: number},
|
||||
'messages_pending': void,
|
||||
'messages_read': void,
|
||||
'messages_downloaded': number[],
|
||||
'messages_downloaded': {peerId: number, mids: number[]},
|
||||
'messages_media_read': {peerId: number, mids: number[]},
|
||||
|
||||
'scheduled_new': {peerId: number, mid: number},
|
||||
|
Loading…
x
Reference in New Issue
Block a user