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