|
|
@ -265,8 +265,8 @@ export class AppDialogsManager { |
|
|
|
const dialog = appMessagesManager.getDialogByPeerId(user.id)[0]; |
|
|
|
const dialog = appMessagesManager.getDialogByPeerId(user.id)[0]; |
|
|
|
//console.log('updating user:', user, dialog);
|
|
|
|
//console.log('updating user:', user, dialog);
|
|
|
|
|
|
|
|
|
|
|
|
if(dialog && !appUsersManager.isBot(dialog.peerId) && dialog.peerId != rootScope.myId) { |
|
|
|
if(dialog && !appUsersManager.isBot(dialog.peerId) && dialog.peerId !== rootScope.myId) { |
|
|
|
const online = user.status?._ == 'userStatusOnline'; |
|
|
|
const online = user.status?._ === 'userStatusOnline'; |
|
|
|
const dom = this.getDialogDom(dialog.peerId); |
|
|
|
const dom = this.getDialogDom(dialog.peerId); |
|
|
|
|
|
|
|
|
|
|
|
if(dom) { |
|
|
|
if(dom) { |
|
|
@ -348,13 +348,13 @@ export class AppDialogsManager { |
|
|
|
|
|
|
|
|
|
|
|
//const perf = performance.now();
|
|
|
|
//const perf = performance.now();
|
|
|
|
for(const element of this.lastActiveElements) { |
|
|
|
for(const element of this.lastActiveElements) { |
|
|
|
if(+element.getAttribute('data-peerid') !== peerId) { |
|
|
|
if(+element.dataset.peerId !== peerId) { |
|
|
|
element.classList.remove('active'); |
|
|
|
element.classList.remove('active'); |
|
|
|
this.lastActiveElements.delete(element); |
|
|
|
this.lastActiveElements.delete(element); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const elements = Array.from(document.querySelectorAll(`[data-autonomous="0"] li[data-peerid="${peerId}"]`)) as HTMLElement[]; |
|
|
|
const elements = Array.from(document.querySelectorAll(`[data-autonomous="0"] li[data-peer-id="${peerId}"]`)) as HTMLElement[]; |
|
|
|
elements.forEach(element => { |
|
|
|
elements.forEach(element => { |
|
|
|
element.classList.add('active'); |
|
|
|
element.classList.add('active'); |
|
|
|
this.lastActiveElements.add(element); |
|
|
|
this.lastActiveElements.add(element); |
|
|
@ -367,7 +367,7 @@ export class AppDialogsManager { |
|
|
|
if(!this.filtersRendered[filter.id]) { |
|
|
|
if(!this.filtersRendered[filter.id]) { |
|
|
|
this.addFilter(filter); |
|
|
|
this.addFilter(filter); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} else if(filter.id == this.filterId) { // это нет тут смысла вызывать, так как будет dialogs_multiupdate
|
|
|
|
} else if(filter.id === this.filterId) { // это нет тут смысла вызывать, так как будет dialogs_multiupdate
|
|
|
|
//this.validateForFilter();
|
|
|
|
//this.validateForFilter();
|
|
|
|
const folder = appMessagesManager.dialogsStorage.getFolder(filter.id); |
|
|
|
const folder = appMessagesManager.dialogsStorage.getFolder(filter.id); |
|
|
|
this.validateForFilter(); |
|
|
|
this.validateForFilter(); |
|
|
@ -442,7 +442,7 @@ export class AppDialogsManager { |
|
|
|
|
|
|
|
|
|
|
|
id = +tabContent.dataset.filterId || 0; |
|
|
|
id = +tabContent.dataset.filterId || 0; |
|
|
|
|
|
|
|
|
|
|
|
if(this.filterId == id) return; |
|
|
|
if(this.filterId === id) return; |
|
|
|
|
|
|
|
|
|
|
|
this.chatLists[id].innerHTML = ''; |
|
|
|
this.chatLists[id].innerHTML = ''; |
|
|
|
this.scroll.setVirtualContainer(this.chatLists[id]); |
|
|
|
this.scroll.setVirtualContainer(this.chatLists[id]); |
|
|
@ -492,9 +492,9 @@ export class AppDialogsManager { |
|
|
|
|
|
|
|
|
|
|
|
get topOffsetIndex() { |
|
|
|
get topOffsetIndex() { |
|
|
|
if(!this.scroll.loadedAll['top']) { |
|
|
|
if(!this.scroll.loadedAll['top']) { |
|
|
|
const element = this.chatList.firstElementChild; |
|
|
|
const element = this.chatList.firstElementChild as HTMLElement; |
|
|
|
if(element) { |
|
|
|
if(element) { |
|
|
|
const peerId = +element.getAttribute('data-peerId'); |
|
|
|
const peerId = +element.dataset.peerId; |
|
|
|
const dialog = appMessagesManager.getDialogByPeerId(peerId)[0]; |
|
|
|
const dialog = appMessagesManager.getDialogByPeerId(peerId)[0]; |
|
|
|
return dialog.index; |
|
|
|
return dialog.index; |
|
|
|
} |
|
|
|
} |
|
|
@ -584,7 +584,7 @@ export class AppDialogsManager { |
|
|
|
const span = document.createElement('span'); |
|
|
|
const span = document.createElement('span'); |
|
|
|
const titleSpan = document.createElement('span'); |
|
|
|
const titleSpan = document.createElement('span'); |
|
|
|
titleSpan.innerHTML = RichTextProcessor.wrapEmojiText(filter.title); |
|
|
|
titleSpan.innerHTML = RichTextProcessor.wrapEmojiText(filter.title); |
|
|
|
const unreadSpan = document.createElement('span'); |
|
|
|
const unreadSpan = document.createElement('div'); |
|
|
|
unreadSpan.classList.add('badge', 'badge-20', 'badge-blue'); |
|
|
|
unreadSpan.classList.add('badge', 'badge-20', 'badge-blue'); |
|
|
|
const i = document.createElement('i'); |
|
|
|
const i = document.createElement('i'); |
|
|
|
span.append(titleSpan, unreadSpan, i); |
|
|
|
span.append(titleSpan, unreadSpan, i); |
|
|
@ -643,18 +643,18 @@ export class AppDialogsManager { |
|
|
|
let offsetIndex = 0; |
|
|
|
let offsetIndex = 0; |
|
|
|
|
|
|
|
|
|
|
|
if(side == 'top') { |
|
|
|
if(side == 'top') { |
|
|
|
const element = this.chatList.firstElementChild; |
|
|
|
const element = this.chatList.firstElementChild as HTMLElement; |
|
|
|
if(element) { |
|
|
|
if(element) { |
|
|
|
const peerId = +element.getAttribute('data-peerId'); |
|
|
|
const peerId = +element.dataset.peerId; |
|
|
|
const index = storage.findIndex(dialog => dialog.peerId == peerId); |
|
|
|
const index = storage.findIndex(dialog => dialog.peerId == peerId); |
|
|
|
const needIndex = Math.max(0, index - loadCount); |
|
|
|
const needIndex = Math.max(0, index - loadCount); |
|
|
|
loadCount = index - needIndex; |
|
|
|
loadCount = index - needIndex; |
|
|
|
offsetIndex = storage[needIndex].index + 1; |
|
|
|
offsetIndex = storage[needIndex].index + 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const element = this.chatList.lastElementChild; |
|
|
|
const element = this.chatList.lastElementChild as HTMLElement; |
|
|
|
if(element) { |
|
|
|
if(element) { |
|
|
|
const peerId = +element.getAttribute('data-peerId'); |
|
|
|
const peerId = +element.dataset.peerId; |
|
|
|
const dialog = storage.find(dialog => dialog.peerId == peerId); |
|
|
|
const dialog = storage.find(dialog => dialog.peerId == peerId); |
|
|
|
offsetIndex = dialog.index; |
|
|
|
offsetIndex = dialog.index; |
|
|
|
} |
|
|
|
} |
|
|
@ -786,7 +786,7 @@ export class AppDialogsManager { |
|
|
|
|
|
|
|
|
|
|
|
sliced.forEach(el => { |
|
|
|
sliced.forEach(el => { |
|
|
|
el.remove(); |
|
|
|
el.remove(); |
|
|
|
const peerId = +el.getAttribute('data-peerId'); |
|
|
|
const peerId = +el.dataset.peerId; |
|
|
|
delete this.doms[peerId]; |
|
|
|
delete this.doms[peerId]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -848,7 +848,7 @@ export class AppDialogsManager { |
|
|
|
if(elem) { |
|
|
|
if(elem) { |
|
|
|
if(onFound) onFound(); |
|
|
|
if(onFound) onFound(); |
|
|
|
|
|
|
|
|
|
|
|
let peerId = +elem.getAttribute('data-peerId'); |
|
|
|
let peerId = +elem.dataset.peerId; |
|
|
|
let lastMsgId = +elem.dataset.mid || undefined; |
|
|
|
let lastMsgId = +elem.dataset.mid || undefined; |
|
|
|
|
|
|
|
|
|
|
|
appImManager.setPeer(peerId, lastMsgId); |
|
|
|
appImManager.setPeer(peerId, lastMsgId); |
|
|
@ -861,7 +861,7 @@ export class AppDialogsManager { |
|
|
|
list.addEventListener('dblclick', (e) => { |
|
|
|
list.addEventListener('dblclick', (e) => { |
|
|
|
const li = findUpTag(e.target, 'LI'); |
|
|
|
const li = findUpTag(e.target, 'LI'); |
|
|
|
if(li) { |
|
|
|
if(li) { |
|
|
|
const peerId = +li.getAttribute('data-peerId'); |
|
|
|
const peerId = +li.dataset.peerId; |
|
|
|
this.log('debug dialog:', appMessagesManager.getDialogByPeerId(peerId)); |
|
|
|
this.log('debug dialog:', appMessagesManager.getDialogByPeerId(peerId)); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -879,16 +879,16 @@ export class AppDialogsManager { |
|
|
|
this.reorderDialogsTimeout = 0; |
|
|
|
this.reorderDialogsTimeout = 0; |
|
|
|
let offset = 0; |
|
|
|
let offset = 0; |
|
|
|
if(this.topOffsetIndex) { |
|
|
|
if(this.topOffsetIndex) { |
|
|
|
const element = this.chatList.firstElementChild; |
|
|
|
const element = this.chatList.firstElementChild as HTMLElement; |
|
|
|
if(element) { |
|
|
|
if(element) { |
|
|
|
const peerId = +element.getAttribute('data-peerId'); |
|
|
|
const peerId = +element.dataset.peerId; |
|
|
|
const firstDialog = appMessagesManager.getDialogByPeerId(peerId); |
|
|
|
const firstDialog = appMessagesManager.getDialogByPeerId(peerId); |
|
|
|
offset = firstDialog[1]; |
|
|
|
offset = firstDialog[1]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const dialogs = appMessagesManager.dialogsStorage.getFolder(this.filterId); |
|
|
|
const dialogs = appMessagesManager.dialogsStorage.getFolder(this.filterId); |
|
|
|
const currentOrder = (Array.from(this.chatList.children) as HTMLElement[]).map(el => +el.getAttribute('data-peerId')); |
|
|
|
const currentOrder = (Array.from(this.chatList.children) as HTMLElement[]).map(el => +el.dataset.peerId); |
|
|
|
|
|
|
|
|
|
|
|
dialogs.forEach((dialog, index) => { |
|
|
|
dialogs.forEach((dialog, index) => { |
|
|
|
const dom = this.getDialogDom(dialog.peerId); |
|
|
|
const dom = this.getDialogDom(dialog.peerId); |
|
|
@ -936,7 +936,7 @@ export class AppDialogsManager { |
|
|
|
lastMessage = appMessagesManager.getMessageByPeer(dialog.peerId, dialog.top_message); |
|
|
|
lastMessage = appMessagesManager.getMessageByPeer(dialog.peerId, dialog.top_message); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(lastMessage._ == 'messageEmpty' || (lastMessage._ == 'messageService' && !lastMessage.rReply)) { |
|
|
|
if(lastMessage._ === 'messageEmpty' || (lastMessage._ === 'messageService' && !lastMessage.rReply)) { |
|
|
|
dom.lastMessageSpan.innerHTML = ''; |
|
|
|
dom.lastMessageSpan.innerHTML = ''; |
|
|
|
dom.lastTimeSpan.innerHTML = ''; |
|
|
|
dom.lastTimeSpan.innerHTML = ''; |
|
|
|
delete dom.listEl.dataset.mid; |
|
|
|
delete dom.listEl.dataset.mid; |
|
|
@ -1071,7 +1071,7 @@ export class AppDialogsManager { |
|
|
|
} else dom.statusSpan.classList.remove('tgico-check', 'tgico-checks'); |
|
|
|
} else dom.statusSpan.classList.remove('tgico-check', 'tgico-checks'); |
|
|
|
|
|
|
|
|
|
|
|
dom.unreadMessagesSpan.innerText = ''; |
|
|
|
dom.unreadMessagesSpan.innerText = ''; |
|
|
|
dom.unreadMessagesSpan.classList.remove('tgico-pinnedchat'); |
|
|
|
dom.unreadMessagesSpan.classList.remove('tgico-pinnedchat', 'tgico'); |
|
|
|
|
|
|
|
|
|
|
|
const filter = appMessagesManager.filtersStorage.filters[this.filterId]; |
|
|
|
const filter = appMessagesManager.filtersStorage.filters[this.filterId]; |
|
|
|
let isPinned: boolean; |
|
|
|
let isPinned: boolean; |
|
|
@ -1088,7 +1088,7 @@ export class AppDialogsManager { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
dom.unreadMessagesSpan.classList.remove('unread'); |
|
|
|
dom.unreadMessagesSpan.classList.remove('unread'); |
|
|
|
if(isPinned) { |
|
|
|
if(isPinned) { |
|
|
|
dom.unreadMessagesSpan.classList.add('tgico-pinnedchat'); |
|
|
|
dom.unreadMessagesSpan.classList.add('tgico-pinnedchat', 'tgico'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1222,7 +1222,7 @@ export class AppDialogsManager { |
|
|
|
|
|
|
|
|
|
|
|
const li = document.createElement('li'); |
|
|
|
const li = document.createElement('li'); |
|
|
|
li.append(paddingDiv); |
|
|
|
li.append(paddingDiv); |
|
|
|
li.setAttribute('data-peerId', '' + peerId); |
|
|
|
li.dataset.peerId = '' + peerId; |
|
|
|
|
|
|
|
|
|
|
|
const statusSpan = document.createElement('span'); |
|
|
|
const statusSpan = document.createElement('span'); |
|
|
|
statusSpan.classList.add('message-status'); |
|
|
|
statusSpan.classList.add('message-status'); |
|
|
@ -1230,8 +1230,8 @@ export class AppDialogsManager { |
|
|
|
const lastTimeSpan = document.createElement('span'); |
|
|
|
const lastTimeSpan = document.createElement('span'); |
|
|
|
lastTimeSpan.classList.add('message-time'); |
|
|
|
lastTimeSpan.classList.add('message-time'); |
|
|
|
|
|
|
|
|
|
|
|
const unreadMessagesSpan = document.createElement('span'); |
|
|
|
const unreadMessagesSpan = document.createElement('div'); |
|
|
|
unreadMessagesSpan.classList.add('dialog-subtitle-badge'); |
|
|
|
unreadMessagesSpan.className = 'dialog-subtitle-badge badge badge-24'; |
|
|
|
|
|
|
|
|
|
|
|
const titleP = document.createElement('p'); |
|
|
|
const titleP = document.createElement('p'); |
|
|
|
titleP.classList.add('dialog-title'); |
|
|
|
titleP.classList.add('dialog-title'); |
|
|
|