Drop local dialog when draft is emptied
This commit is contained in:
parent
c4512f205a
commit
96531d36e9
@ -83,7 +83,7 @@ export default class AutocompletePeerHelper extends AutocompleteHelper {
|
||||
div.dataset.peerId = '' + options.peerId;
|
||||
|
||||
const avatar = new AvatarElement();
|
||||
avatar.classList.add('avatar-30', options.className + '-avatar');
|
||||
avatar.classList.add('avatar-30', BASE + '-avatar', options.className + '-avatar');
|
||||
avatar.setAttribute('dialog', '0');
|
||||
avatar.setAttribute('peer', '' + options.peerId);
|
||||
|
||||
|
@ -558,7 +558,10 @@ export class AppDialogsManager {
|
||||
|
||||
private updateDialog(dialog: Dialog) {
|
||||
if(this.isDialogMustBeInViewport(dialog)) {
|
||||
this.sortedList.add(dialog.peerId);
|
||||
if(!this.sortedList.has(dialog.peerId)) {
|
||||
this.sortedList.add(dialog.peerId);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.deleteDialog(dialog.peerId);
|
||||
return;
|
||||
@ -1286,6 +1289,11 @@ export class AppDialogsManager {
|
||||
dom.lastMessageSpan.innerHTML = '';
|
||||
dom.lastTimeSpan.innerHTML = '';
|
||||
delete dom.listEl.dataset.mid;
|
||||
|
||||
if(setUnread) {
|
||||
this.setUnreadMessages(dialog, dom, isBatch);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1334,6 +1342,8 @@ export class AppDialogsManager {
|
||||
fragment = appMessagesManager.wrapMessageForReply(draftMessage);
|
||||
} else if(!lastMessage.deleted) {
|
||||
fragment = appMessagesManager.wrapMessageForReply(lastMessage, undefined, undefined, false, undefined, withoutMediaType);
|
||||
} else { // rare case
|
||||
fragment = document.createDocumentFragment();
|
||||
}
|
||||
|
||||
if(mediaContainer) {
|
||||
|
@ -295,16 +295,24 @@ export class AppMessagesManager {
|
||||
if(threadId) return;
|
||||
|
||||
const dialog = this.getDialogOnly(peerId);
|
||||
if(dialog && !threadId) {
|
||||
dialog.draft = draft;
|
||||
this.dialogsStorage.generateIndexForDialog(dialog);
|
||||
this.dialogsStorage.pushDialog(dialog);
|
||||
if(dialog) {
|
||||
if(!threadId) {
|
||||
dialog.draft = draft;
|
||||
|
||||
rootScope.dispatchEvent('dialog_draft', {
|
||||
peerId,
|
||||
draft,
|
||||
index: dialog.index
|
||||
});
|
||||
if(!draft && !appMessagesIdsManager.getServerMessageId(dialog.top_message)) {
|
||||
this.dialogsStorage.dropDialogWithEvent(peerId);
|
||||
return;
|
||||
}
|
||||
|
||||
this.dialogsStorage.generateIndexForDialog(dialog);
|
||||
this.dialogsStorage.pushDialog(dialog);
|
||||
|
||||
rootScope.dispatchEvent('dialog_draft', {
|
||||
peerId,
|
||||
draft,
|
||||
index: dialog.index
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.reloadConversation(peerId);
|
||||
}
|
||||
|
@ -98,10 +98,7 @@ export default class DialogsStorage {
|
||||
|
||||
const peerId = -chatId;
|
||||
if(chat.pFlags.left && this.getDialogOnly(peerId)) {
|
||||
const dropped = this.dropDialog(peerId);
|
||||
if(dropped.length) {
|
||||
rootScope.dispatchEvent('dialog_drop', {peerId, dialog: dropped[0]});
|
||||
}
|
||||
this.dropDialogWithEvent(peerId);
|
||||
}
|
||||
});
|
||||
|
||||
@ -450,6 +447,13 @@ export default class DialogsStorage {
|
||||
return foundDialog;
|
||||
}
|
||||
|
||||
public dropDialogWithEvent(peerId: number) {
|
||||
const dropped = this.dropDialog(peerId);
|
||||
if(dropped.length) {
|
||||
rootScope.dispatchEvent('dialog_drop', {peerId, dialog: dropped[0]});
|
||||
}
|
||||
}
|
||||
|
||||
public applyDialogs(dialogsResult: MessagesPeerDialogs.messagesPeerDialogs) {
|
||||
// * В эту функцию попадут только те диалоги, в которых есть read_inbox_max_id и read_outbox_max_id, в отличие от тех, что будут в getTopMessages
|
||||
|
||||
@ -489,10 +493,7 @@ export default class DialogsStorage {
|
||||
this.saveDialog(dialog);
|
||||
updatedDialogs[peerId] = dialog;
|
||||
} else {
|
||||
const dropped = this.dropDialog(peerId);
|
||||
if(dropped.length) {
|
||||
rootScope.dispatchEvent('dialog_drop', {peerId, dialog: dropped[0]});
|
||||
}
|
||||
this.dropDialogWithEvent(peerId);
|
||||
}
|
||||
|
||||
const updates = this.appMessagesManager.newUpdatesAfterReloadToHandle[peerId];
|
||||
|
@ -24,16 +24,22 @@
|
||||
position: relative;
|
||||
line-height: var(--line-height);
|
||||
|
||||
@include respond-to(handhelds) {
|
||||
padding-right: .75rem;
|
||||
}
|
||||
|
||||
@include hover();
|
||||
|
||||
&-name {
|
||||
margin-left: .875rem;
|
||||
font-weight: 500;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
&-description {
|
||||
margin-left: .5625rem;
|
||||
color: var(--secondary-text-color);
|
||||
@include text-overflow();
|
||||
}
|
||||
|
||||
&-avatar {
|
||||
|
Loading…
Reference in New Issue
Block a user